#29865: Add XOR for use in Q Queries
-------------------------------------+-------------------------------------
     Reporter:  Griffith Rees        |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  2.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  xor                  |             Triage Stage:
                                     |  Someday/Maybe
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Nick Pope):

 Replying to [comment:4 Marten Kenbeek]:
 > To be clear, you're talking about logical `XOR`, and not bitwise `XOR`?

 As you've highlighted, this should be for logical `XOR` and not bitwise
 `XOR`. So this is only supported for MariaDB and MySQL which have `XOR`.

 This could be implemented by defining `Q.XOR` and `Q.__xor__()` and then
 propagating that around the place.
 It could be possible to support this for other backends by specifying
 `connection.features.supports_logical_xor = False` and then writing out
 the query differently.

 For `Q(a=1) ^ Q(b=2)`, the supporting backends would output `(a = 1 XOR a
 = 2)`, while the others could output `((a = 1 OR b = 2) AND NOT (a = 1 AND
 b = 2))`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29865#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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.152d03c2a56a78ce53947dbb68fd56ca%40djangoproject.com.

Reply via email to