#33963: Combining Q objects with empty querysets crashes.
-------------------------------------+-------------------------------------
     Reporter:  Bogumil Schube       |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Thanks for the report. As far as I'm aware combining querysets (empty or
 not) with `Q()` objects have never been officially supported, documented,
 or tests. This worked for empty querysets in Django 4.0, but accidentally
 and only due to the order of `EmptyQuerySet` guards. You should use `Q()`
 as the starting point for building dynamically `Q` objects, e.g.:
 {{{#!python
 out = Q()
 for a, b in [(1,1),(2,2),(3,3)]:
    out |= Q(a=a, b=b)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33963#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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070182e91379ba-6cfb17c8-c4a8-4a96-bc5c-2065c17206b4-000000%40eu-central-1.amazonses.com.

Reply via email to