#27867: Excluding a reverse relation produces inconsistent queries
-------------------------------------+-------------------------------------
Reporter: Sébastien Diemer | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
I investigated this is a bit and the first non deterministic issue
happened to have been fixed as a side effect
b95c49c954e3b75678bb258e9fb2ec30d0d960bb.
The second issue still stands though but not
[https://github.com/sebdiem/django/commit/e8ca265e8c30f61c88ea17b7c1cab72695d6a4ff
as reported in the test case provided] anymore because
b95c49c954e3b75678bb258e9fb2ec30d0d960bb made `.exclude(name='',
note__isnull=True)` kwargs passed to `Q` always sorted as `[('name', ''),
('note__isnull', True)]` which takes the code path where `U0."id" =
("queries_tag"."id")` is added to the `WHERE` clause.
In order to bypass the kwargs ordering added in
b95c49c954e3b75678bb258e9fb2ec30d0d960bb that hides this issue as reported
because `'name' < 'note'` one can rely on `Q` args instead
1. `exclude(Q(note__isnull=True) & Q(name=''))` exhibits the issue.
2. `exclude(Q(name='') & Q(note__isnull=True))` doesn't as it's equivalent
to what `exclude(name='', note__isnull=True)` translates to.
--
Ticket URL: <https://code.djangoproject.com/ticket/27867#comment:5>
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/065.a9055ef7263abf176a141dc56ace4c59%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.