#23797: SQL generated for negated F() expressions is incorrect
-------------------------------------+-------------------------------------
Reporter: mssnlayam | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by akaariai):
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
Unfortunately this will be messy to fix. It is true that .exclude() should
produce the complement of .filter(), and that doesn't happen here.
One possible solution is to use `WHERE ("testapp_rectangle"."length" =
("testapp_rectangle"."width")) IS NOT true`. This should match both null
and false values (the .filter() query could be written as `WHERE
("testapp_rectangle"."length" = ("testapp_rectangle"."width")) IS true`. I
have no idea how well IS NOT true is optimized, and if it is available for
all backends.
Another possibility is to also filter F() NULL values, but as said that
will be messy.
--
Ticket URL: <https://code.djangoproject.com/ticket/23797#comment:1>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.81821bcdba06cbbebfab2569df365595%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.