Skip to content

Commit

Permalink
fix: datetime value should be seconds in sqlite (#21113)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie authored Aug 18, 2022
1 parent 1ffa567 commit 1afcdfb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superset/db_engine_specs/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def convert_dttm(
) -> 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
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/db_engine_specs/test_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
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:
Expand Down

0 comments on commit 1afcdfb

Please sign in to comment.