You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by yo...@apache.org on 2022/08/18 03:43:05 UTC

[superset] branch master updated: fix: datetime value should be seconds in sqlite (#21113)

This is an automated email from the ASF dual-hosted git repository.

yongjiezhao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 1afcdfb9fa fix: datetime value should be seconds in sqlite (#21113)
1afcdfb9fa is described below

commit 1afcdfb9fa47184f4ee54a57fa9d1985bb2ec6df
Author: Yongjie Zhao <yo...@gmail.com>
AuthorDate: Thu Aug 18 11:42:58 2022 +0800

    fix: datetime value should be seconds in sqlite (#21113)
---
 superset/db_engine_specs/sqlite.py              | 2 +-
 tests/unit_tests/db_engine_specs/test_sqlite.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/superset/db_engine_specs/sqlite.py b/superset/db_engine_specs/sqlite.py
index b82b498c16..3dfe647e37 100644
--- a/superset/db_engine_specs/sqlite.py
+++ b/superset/db_engine_specs/sqlite.py
@@ -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
diff --git a/tests/unit_tests/db_engine_specs/test_sqlite.py b/tests/unit_tests/db_engine_specs/test_sqlite.py
index 576f4ef9e9..03470173dc 100644
--- a/tests/unit_tests/db_engine_specs/test_sqlite.py
+++ b/tests/unit_tests/db_engine_specs/test_sqlite.py
@@ -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: