#26517: Empty Querset Using Empty Queryset in ExpressionWrapper
-------------------------------------+-------------------------------------
     Reporter:  srkunze              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by jarshwah):

 FYI ExpressionWrapper was never meant to be used to wrap up Q() objects.
 Q() are not really expressions themselves, they just implement some of the
 same API internally.

 You're much better off using Case Expressions
 https://docs.djangoproject.com/en/1.9/ref/models/conditional-expressions/
 for this use case:

 {{{
 MyModel.objects.annotate(editable=Case(When(pk__in=[editable], then=1),
 default=0, output_field=BooleanField()) )
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26517#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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.764c35a52f20afcd5acba2993022a6ac%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to