Skip to content

Commit

Permalink
fix: is_temporal should overwrite is_dttm (apache#14894)
Browse files Browse the repository at this point in the history
* fix: is_temporal should overwrite is_dttm

* move up
  • Loading branch information
zhaoyongjie authored and cccs-RyanS committed Dec 17, 2021
1 parent 1c6228d commit 213197b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ def db_engine_spec(self) -> Type[BaseEngineSpec]:

@property
def type_generic(self) -> Optional[utils.GenericDataType]:
if self.is_dttm:
return GenericDataType.TEMPORAL
column_spec = self.db_engine_spec.get_column_spec(self.type)
return column_spec.generic_type if column_spec else None

Expand Down
4 changes: 4 additions & 0 deletions tests/sqla_models_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ def test_db_column_types(self):
self.assertEqual(col.is_numeric, db_col_type == GenericDataType.NUMERIC)
self.assertEqual(col.is_string, db_col_type == GenericDataType.STRING)

for str_type, db_col_type in test_cases.items():
col = TableColumn(column_name="foo", type=str_type, table=tbl, is_dttm=True)
self.assertTrue(col.is_temporal)

@patch("superset.jinja_context.g")
def test_extra_cache_keys(self, flask_g):
flask_g.user.username = "abc"
Expand Down

0 comments on commit 213197b

Please sign in to comment.