#33374: ExpressionWrapper for ~Q(pk__in=[]) broken
-------------------------------+--------------------------------------
     Reporter:  Stefan Brand   |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  Uncategorized  |                  Version:  3.1
     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
-------------------------------+--------------------------------------
Description changed by Stefan Brand:

Old description:

> == Problem Description
>
> I'm reducing some Q objects (similar to what is described in
> ticket:32554. Everything is fine for the case where the result is
> `ExpressionWrapper(Q(pk__in=[]))`. However, when I reduce to
> `ExpressionWrapper(~Q(pk__in=[]))` the query breaks.
>
> == Symptoms
>
> === Working for `ExpressionWrapper(Q(pk__in=[]))`
> {{{#!python
> print(queryset.annotate(foo=ExpressionWrapper(Q(pk__in=[]),
> output_field=BooleanField())).values("foo").query)
> }}}
>
> {{{#!sql
> SELECT 0 AS "foo" FROM "agri_data_declaration"
> }}}
>
> === Not working for `ExpressionWrapper(~Q(pk__in=[]))`
>
> {{{#!python
> print(queryset.annotate(foo=ExpressionWrapper(~Q(pk__in=[]),
> output_field=BooleanField())).values("foo").query)
> }}}
> {{{#!sql
> SELECT  AS "foo" FROM "agri_data_declaration"
> }}}

New description:

 == Problem Description

 I'm reducing some Q objects (similar to what is described in ticket:32554.
 Everything is fine for the case where the result is
 `ExpressionWrapper(Q(pk__in=[]))`. However, when I reduce to
 `ExpressionWrapper(~Q(pk__in=[]))` the query breaks.

 == Symptoms

 === Working for `ExpressionWrapper(Q(pk__in=[]))`
 {{{#!python
 print(queryset.annotate(foo=ExpressionWrapper(Q(pk__in=[]),
 output_field=BooleanField())).values("foo").query)
 }}}

 {{{#!sql
 SELECT 0 AS "foo" FROM "table"
 }}}

 === Not working for `ExpressionWrapper(~Q(pk__in=[]))`

 {{{#!python
 print(queryset.annotate(foo=ExpressionWrapper(~Q(pk__in=[]),
 output_field=BooleanField())).values("foo").query)
 }}}
 {{{#!sql
 SELECT  AS "foo" FROM "table"
 }}}

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33374#comment:2>
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/069.048747f66f0f3e3e2643aed7a139ab42%40djangoproject.com.

Reply via email to