#32651: Combining Q with a Q containing Exists crashes
-------------------------------------+-------------------------------------
     Reporter:  Jaap Roes            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Jaap Roes):

 I figured out why the tests results where different, for some reason
 combining a `Q` with a negated `Exists` (using the `~` operator) results
 in an unnegated `Exists`:

 {{{
 >>> q = Q() & ~Exists(Book.objects.all())
 >>> q.negated
 False
 }}}

 Setting `negated` on the constructor does work:

 {{{
 >>> q = Q() & Exists(Vacancy.objects.all(), negated=True)
 >>> q.negated
 True
 }}}

 This might be a separate bug.

 At least I'm now able to finish the Django 3.2 upgrade.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32651#comment:3>
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.d0306ff6c90d30ee82c2512dab15df3e%40djangoproject.com.

Reply via email to