#35111 closed Bug (fixed)
DateField's __range and __in lookups against expressions produce invalid values on SQLite.
Reported by: | Simon Charette | Owned by: | Simon Charette |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
#22288 (4f138fe5a496a81115c4fba6615a517fc62c3b17) only partially addressed the issue of iterable right-hand-side lookups (__range
and __in
) by adapting Oracle's and SQLite operation modules to special case the adaptation of datetime and time value while missing that date values are still converted to string.
This causes queries of the form
Person.objects.filter( dob__between=(F("dob"), F("dob")) )
To be turned into
SELECT * FROM person WHERE dob BETWEEN "Col('dob')" AND "Col('dob')"
I believe the fundamental flaw in 4f138fe5a496a81115c4fba6615a517fc62c3b17 is that expressions (hasattr(obj, "resolve_expression")
) should never be passed to Field.get_db_prep_value
in the first place during the Lookup
's right-hand-side processing phase just like they are not passed to Field.get_prep_value
during the preparation phase.
Initially discovered on the forum by Joel Feiner.
Change History (7)
comment:1 by , 11 months ago
Has patch: | set |
---|
comment:2 by , 11 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 11 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:4 by , 11 months ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:6 by , 11 months ago
From a quick look I don't think it does Claude as the logic changed here only relates to lookups. In other words, RangeField
and RangeLookup
are completely different beasts.
In 0fcee16: