Opened 3 years ago

Last modified 20 months ago

#33374 closed Bug

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

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

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(declarations.annotate(foo=ExpressionWrapper(~Q(pk__in=[]), output_field=BooleanField())).values("foo").query)
SELECT  AS "foo" FROM "agri_data_declaration"

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top