#32548: Support passing conditional expressions to Q().
-------------------------------------+-------------------------------------
Reporter: jonathan-golorry | Owner: jonathan-
Type: | golorry
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: Q objects, | Triage Stage: Accepted
deconstruct |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by jonathan-golorry):
I suppose it's a semantics argument whether `Q(Exists...)` is untested if
there's a test that runs that exact expression, but isn't solely checking
that functionality.
My point is that `Q(("x", 1))` and `Q(x=1)` are equivalent, so it's
impossible for the deconstruct to correctly recreate the original args and
kwargs in all cases. Therefore, unless there's an argument for keeping the
special case, it's better to consistently use args for both `Q(x=1)` and
`Q(x=1, y=2)`.
I point out `Q(Exists...) | Q(Q())` to show that the fragility of the
special case is problematic and hard to catch. An internal optimization
for nested empty Q objects can cause conditional expression combination to
fail. That's why I'd like this patch to be focused on removing the special
case and making Q objects more robust for all inputs, rather than only
adding support for expressions. Both would make my future work on Q
objects possible, but the current patch would put django in a better
position for future development.
--
Ticket URL: <https://code.djangoproject.com/ticket/32548#comment:6>
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/074.139c4de4b81d4247699295297f5a12fd%40djangoproject.com.