#32549: Add `Q.empty()` to check for nested empty Q objects like `Q(Q())`
-------------------------------------+-------------------------------------
     Reporter:  jonathan-golorry     |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  Q objects, nested,   |             Triage Stage:
  empty                              |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

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


Comment:

 Replying to [comment:3 jonathan-golorry]:
 > Here is an alternate approach that adds a way to check for nested empty
 Q objects instead of making them impossible to create.

 It looks that you need `Q.empty()` as a hook for #32554 (to which I'm also
 not convinced, but we can discuss this in #32554). I don't think that we
 need this as a standalone feature. Moreover it's still backward
 incompatible, because it changes the current behavior when combining a
 nested `Q()` objects. It's also inconsistent with the current API and
 quite misleading, e.g.
 {{{
 >>> from django.db.models import Q
 >>> q = Q(Q())
 >>> q.empty()
 True
 >>> len(q)
 1
 >>> bool(q)
 True
 }}}

 I understand that you need this for building generic nested queries but
 it's not needed for most users. You can always use your own subclass of
 `Q` and even release it as a third-party package.

 [https://docs.djangoproject.com/en/stable/internals/contributing/triaging-
 tickets/#closing-tickets Please follow triaging guidelines with regards to
 wontfix tickets.]

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32549#comment:4>
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/074.cf6e16fef6904b945495b1108b0e9e3e%40djangoproject.com.

Reply via email to