handle null column_name in sqla and druid models

This commit is contained in:
Grace Guo
2019-03-19 11:58:11 -07:00
parent e83a07d3df
commit 2ff721ae07
2 changed files with 5 additions and 3 deletions

View File

@@ -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]'))

View File

@@ -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):