willbarrett commented on a change in pull request #8464: [SIP-15] Fixing 
datetime conversion and SQL literal
URL: 
https://github.com/apache/incubator-superset/pull/8464#discussion_r340326338
 
 

 ##########
 File path: superset/db_engine_specs/sqlite.py
 ##########
 @@ -75,11 +75,10 @@ def get_all_datasource_names(
             raise Exception(f"Unsupported datasource_type: {datasource_type}")
 
     @classmethod
-    def convert_dttm(cls, target_type: str, dttm: datetime) -> str:
-        iso = dttm.isoformat().replace("T", " ")
-        if "." not in iso:
-            iso += ".000000"
-        return "'{}'".format(iso)
+    def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
+        if target_type.upper() == "TEXT":
+            return f"""'{dttm.isoformat(sep=" ", timespec="microseconds")}'"""
+        return None
 
 Review comment:
   SQLite also supports time stored in REAL and INTEGER columns according to 
the docs:
   
   ```
       TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS").
       REAL as Julian day numbers, the number of days since noon in Greenwich 
on November 24, 4714 B.C. according to the proleptic Gregorian calendar.
       INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 
UTC.
   ```
   Should we support the REAL and INTEGER conversions here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to