bito-code-review[bot] commented on code in PR #44805:
URL: https://github.com/apache/superset/pull/44805#discussion_r4136426102
##########
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:
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Midnight branch catches DateTime</b></div>
<div id="fix">
`types.DateTime` and `types.TIMESTAMP` subclass `types.Date` in SQLAlchemy,
so `isinstance(sqla_type, types.Date)` at line 177 also fires for
DateTime/TIMESTAMP columns at midnight, emitting a bare date. This contradicts
the new tests: `test_convert_dttm_midnight` expects `'2019-01-02 00:00:00'` for
DateTime/TimeStamp and `test_convert_dttm_date` expects `'2026-09-20 00:00:00'`
for DATETIME — both would fail, and DateTime midnight bounds get wrong
text-comparison semantics. Exclude DateTime: `isinstance(sqla_type, types.Date)
and not isinstance(sqla_type, types.DateTime)`.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
if (
isinstance(sqla_type, types.Date)
and not isinstance(sqla_type, types.DateTime)
and dttm.time() == time.min
):
````
</div>
</details>
</div>
<small><i>Code Review Run #63f777</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]