{{{
>>> from django.db.models import Q
>>> from my_app.models import Client
>>> Client.objects.filter(Q(id=37)).count()
1
>>> Client.objects.filter(Q(id=37) ^ Q(id=37)).count()
0
>>> Client.objects.filter(Q(id=37) ^ Q(id=37) ^ Q(id=37)).count()
0
>>> Client.objects.filter(Q(id=37) ^ Q(id=37) ^ Q(id=37) ^
Q(id=37)).count()
0
>>> Client.objects.filter(Q(id=37) ^ Q(id=37) ^ Q(id=37) ^ Q(id=37) ^
Q(id=37)).count()
0
}}}
(Expected: `1`, `0`, `1`, `0`, `1`.)
This was introduced in #29865.
--
Ticket URL: <https://code.djangoproject.com/ticket/34604>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => Anders Kaseorg
* status: new => assigned
* has_patch: 0 => 1
Comment:
Submitted a patch at https://github.com/django/django/pull/16736.
--
Ticket URL: <https://code.djangoproject.com/ticket/34604#comment:1>
* cc: Ryan Heard (added)
* needs_better_patch: 0 => 1
* stage: Unreviewed => Accepted
* needs_docs: 0 => 1
Comment:
Thanks for the report.
[https://github.com/django/django/pull/16901 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/34604#comment:2>
* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/34604#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"b81e974e9ea16bd693b194a728f77fb825ec8e54" b81e974]:
{{{
#!CommitTicketReference repository=""
revision="b81e974e9ea16bd693b194a728f77fb825ec8e54"
Fixed #34604 -- Corrected fallback SQL for n-ary logical XOR.
An n-ary logical XOR Q(…) ^ Q(…) ^ … ^ Q(…) should evaluate to true
when an odd number of its operands evaluate to true, not when exactly
one operand evaluates to true.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34604#comment:4>