fix: is_temporal should overwrite is_dttm (#14894)

* fix: is_temporal should overwrite is_dttm

* move up
This commit is contained in:
Yongjie Zhao
2021-06-02 11:00:15 +01:00
committed by GitHub
parent b6f00e69e1
commit f4de0dcb65
2 changed files with 6 additions and 0 deletions

View File

@@ -230,6 +230,8 @@ class TableColumn(Model, BaseColumn):
@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

View File

@@ -102,6 +102,10 @@ class TestDatabaseModel(SupersetTestCase):
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"