ExpressionWrapper for ~Q(pk__in=[]) crashes.
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=[]))
print(queryset.annotate(foo=ExpressionWrapper(Q(pk__in=[]), output_field=BooleanField())).values("foo").query)
SELECT 0 AS "foo" FROM "table"
Not working for ExpressionWrapper(~Q(pk__in=[]))
print(queryset.annotate(foo=ExpressionWrapper(~Q(pk__in=[]), output_field=BooleanField())).values("foo").query)
SELECT AS "foo" FROM "table"
Change History
(10)
Description: |
modified (diff)
|
Description: |
modified (diff)
|
Component: |
Uncategorized → Database layer (models, ORM)
|
Summary: |
ExpressionWrapper for ~Q(pk__in=[]) broken → ExpressionWrapper for ~Q(pk__in=[]) crashes.
|
Triage Stage: |
Unreviewed → Accepted
|
Cc: |
David Wobrock added
|
Has patch: |
set
|
Owner: |
changed from nobody to David Wobrock
|
Status: |
new → assigned
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Good catch!