#35111: DateField's __range and __in lookups against expressions produce invalid
values on SQLite.
-------------------------------------+-------------------------------------
Reporter: Simon | Owner: nobody
Charette |
Type: Bug | Status: new
Component: Database | Version: 5.0
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
#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
{{{#!python
Person.objects.filter(
dob__between=(F("dob"), F("dob"))
)
}}}
To be turned into
{{{#!sql
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`
[https://github.com/django/django/blob/92d6cff6a2fee7a3f9244081b84fd82c50cc71aa/django/db/models/lookups.py#L287-L295
during the preparation phase].
Initially discovered on [https://forum.djangoproject.com/t/range-lookup-
with-complex-expressions/26795/7 the forum] by Joel Feiner.
--
Ticket URL: <https://code.djangoproject.com/ticket/35111>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018d04ad275a-1fd3bdac-c0a5-469f-8157-ac07c0aeb992-000000%40eu-central-1.amazonses.com.