mirror of
https://github.com/apache/superset.git
synced 2026-06-02 06:09:21 +00:00
handle null column_name in sqla and druid models
This commit is contained in:
@@ -86,7 +86,7 @@ class BaseDatasource(AuditMixinNullable, ImportMixin):
|
||||
|
||||
@property
|
||||
def column_names(self):
|
||||
return sorted([c.column_name for c in self.columns])
|
||||
return sorted([c.column_name for c in self.columns], key=lambda x: x or '')
|
||||
|
||||
@property
|
||||
def columns_types(self):
|
||||
@@ -166,7 +166,9 @@ class BaseDatasource(AuditMixinNullable, ImportMixin):
|
||||
def data(self):
|
||||
"""Data representation of the datasource sent to the frontend"""
|
||||
order_by_choices = []
|
||||
for s in sorted(self.column_names):
|
||||
# self.column_names return sorted column_names
|
||||
for s in self.column_names:
|
||||
s = str(s or '')
|
||||
order_by_choices.append((json.dumps([s, True]), s + ' [asc]'))
|
||||
order_by_choices.append((json.dumps([s, False]), s + ' [desc]'))
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ class DruidColumn(Model, BaseColumn):
|
||||
export_parent = 'datasource'
|
||||
|
||||
def __repr__(self):
|
||||
return self.column_name
|
||||
return self.column_name or str(self.id)
|
||||
|
||||
@property
|
||||
def expression(self):
|
||||
|
||||
Reference in New Issue
Block a user