mirror of
https://github.com/apache/superset.git
synced 2026-04-07 10:31:50 +00:00
fix: datetime value should be seconds in sqlite (#21113)
This commit is contained in:
@@ -110,7 +110,7 @@ class SqliteEngineSpec(BaseEngineSpec):
|
||||
) -> Optional[str]:
|
||||
tt = target_type.upper()
|
||||
if tt in (utils.TemporalType.TEXT, utils.TemporalType.DATETIME):
|
||||
return f"""'{dttm.isoformat(sep=" ", timespec="microseconds")}'"""
|
||||
return f"""'{dttm.isoformat(sep=" ", timespec="seconds")}'"""
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -27,13 +27,13 @@ from tests.unit_tests.fixtures.common import dttm
|
||||
def test_convert_dttm(dttm: datetime) -> None:
|
||||
from superset.db_engine_specs.sqlite import SqliteEngineSpec
|
||||
|
||||
assert SqliteEngineSpec.convert_dttm("TEXT", dttm) == "'2019-01-02 03:04:05.678900'"
|
||||
assert SqliteEngineSpec.convert_dttm("TEXT", dttm) == "'2019-01-02 03:04:05'"
|
||||
|
||||
|
||||
def test_convert_dttm_lower(dttm: datetime) -> None:
|
||||
from superset.db_engine_specs.sqlite import SqliteEngineSpec
|
||||
|
||||
assert SqliteEngineSpec.convert_dttm("text", dttm) == "'2019-01-02 03:04:05.678900'"
|
||||
assert SqliteEngineSpec.convert_dttm("text", dttm) == "'2019-01-02 03:04:05'"
|
||||
|
||||
|
||||
def test_convert_dttm_invalid_type(dttm: datetime) -> None:
|
||||
|
||||
Reference in New Issue
Block a user