mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
fix: TemporalWrapperType string representation (#16614)
* fix: TemporalWrapperType string representation * fix tests
This commit is contained in:
@@ -561,11 +561,13 @@ class TestPrestoDbEngineSpec(TestDbEngineSpec):
|
||||
self.assertEqual(column_spec.generic_type, GenericDataType.NUMERIC)
|
||||
|
||||
column_spec = PrestoEngineSpec.get_column_spec("time")
|
||||
assert issubclass(column_spec.sqla_type, types.Time)
|
||||
assert isinstance(column_spec.sqla_type, types.Time)
|
||||
assert type(column_spec.sqla_type).__name__ == "TemporalWrapperType"
|
||||
self.assertEqual(column_spec.generic_type, GenericDataType.TEMPORAL)
|
||||
|
||||
column_spec = PrestoEngineSpec.get_column_spec("timestamp")
|
||||
assert issubclass(column_spec.sqla_type, types.TIMESTAMP)
|
||||
assert isinstance(column_spec.sqla_type, types.TIMESTAMP)
|
||||
assert type(column_spec.sqla_type).__name__ == "TemporalWrapperType"
|
||||
self.assertEqual(column_spec.generic_type, GenericDataType.TEMPORAL)
|
||||
|
||||
sqla_type = PrestoEngineSpec.get_sqla_column_type(None)
|
||||
|
||||
@@ -24,11 +24,14 @@ from tests.integration_tests.fixtures.birth_names_dashboard import (
|
||||
|
||||
import pytest
|
||||
from sqlalchemy.engine.url import make_url
|
||||
from sqlalchemy.types import DateTime
|
||||
|
||||
import tests.integration_tests.test_app
|
||||
from superset import app, db as metadata_db
|
||||
from superset.db_engine_specs.postgres import PostgresEngineSpec
|
||||
from superset.models.core import Database
|
||||
from superset.models.slice import Slice
|
||||
from superset.models.sql_types.base import literal_dttm_type_factory
|
||||
from superset.utils.core import get_example_database, QueryStatus
|
||||
|
||||
from .base_tests import SupersetTestCase
|
||||
@@ -516,3 +519,10 @@ class TestSqlaTableModel(SupersetTestCase):
|
||||
assert set(data_for_slices["verbose_map"].keys()) == set(
|
||||
["__timestamp", "sum__num", "gender",]
|
||||
)
|
||||
|
||||
|
||||
def test_literal_dttm_type_factory():
|
||||
orig_type = DateTime()
|
||||
new_type = literal_dttm_type_factory(orig_type, PostgresEngineSpec, "TIMESTAMP")
|
||||
assert type(new_type).__name__ == "TemporalWrapperType"
|
||||
assert str(new_type) == str(orig_type)
|
||||
|
||||
Reference in New Issue
Block a user