Opened 2 years ago

Last modified 8 months ago

#33482 closed Bug

filter on exists-subquery with emoty queryset removes whole WHERE block — at Version 1

Reported by: Tobias Bengfort Owned by: nobody
Component: Database layer (models, ORM) Version: 4.0
Severity: Normal Keywords: orm, EmptyResultSet, Exists
Cc: 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 Tobias Bengfort)

qs = MyModel.objects.filter(~models.Exists(MyModel.objects.none()), name='test')
qs

<QuerySet []>

print(qs.query)

EmptyResultSet

With django-debug-toolbar I can still see the query, but there WHERE block is missing completely.

This seems to be very similar to #33018.

Change History (1)

comment:1 by Tobias Bengfort, 2 years ago

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