This is an automated email from the ASF dual-hosted git repository.
graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 60a7b6d handle null column_name in sqla and druid models (#7063)
60a7b6d is described below
commit 60a7b6df599262374dc227f7169d6a645dc24db9
Author: Grace Guo <[email protected]>
AuthorDate: Fri Mar 22 20:21:25 2019 -0700
handle null column_name in sqla and druid models (#7063)
---
superset/connectors/base/models.py | 6 ++++--
superset/connectors/druid/models.py | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/superset/connectors/base/models.py
b/superset/connectors/base/models.py
index 39cc585..958bea0 100644
--- a/superset/connectors/base/models.py
+++ b/superset/connectors/base/models.py
@@ -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]'))
diff --git a/superset/connectors/druid/models.py
b/superset/connectors/druid/models.py
index 3b22ade..144d400 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -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):