Opened 3 years ago

Last modified 2 years ago

#33374 closed Bug

ExpressionWrapper for ~Q(pk__in=[]) broken — at Version 1

Reported by: Stefan Brand Owned by: nobody
Component: Database layer (models, ORM) Version: 3.1
Severity: Normal Keywords:
Cc: David Wobrock Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Stefan Brand)

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 "agri_data_declaration"

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 "agri_data_declaration"

Change History (1)

comment:1 by Stefan Brand, 3 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top