danielalyoshin commented on code in PR #44805:
URL: https://github.com/apache/superset/pull/44805#discussion_r4136550084
##########
superset/db_engine_specs/sqlite.py:
##########
@@ -164,8 +164,19 @@ def get_temporal_column_shift_expr(
def convert_dttm(
cls, target_type: str, dttm: datetime, db_extra: dict[str, Any] | None
= None
) -> str | None:
+ """
+ Write midnight as a bare date for DATE columns.
+
+ SQLite has no date type, so a DATE column usually holds text such as
+ ``2026-09-20`` and is compared as text. ``'2026-09-20 00:00:00'`` sorts
+ after the day it starts, so a time filter on a DATE column would be
one day
+ off. Any other time keeps its time part, which sorts between two days,
as a
+ comparison of dates should.
+ """
sqla_type = cls.get_sqla_column_type(target_type)
- if isinstance(sqla_type, (types.String, types.DateTime)):
+ if isinstance(sqla_type, types.Date) and dttm.time() == time.min:
+ return f"'{dttm.date().isoformat()}'"
+ if isinstance(sqla_type, (types.String, types.Date, types.DateTime)):
return f"""'{dttm.isoformat(sep=" ", timespec="seconds")}'"""
Review Comment:
Thanks. This is the trade-off described in the summary. `convert_dttm` only
gets the type name, not the column, so it cannot see `python_date_format`.
SQLite already skips the format for `TEXT` and `DATETIME` columns, and #44505
(D1) and #43355 (Google Sheets) do the same for `DATE`. It applies at midnight
too, and only affects a `DATE` column holding something other than `YYYY-MM-DD`
text. Letting a set format win would fix it for every database and fits better
in a separate PR.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]