From b7d1da5a62fe4141beff2bfea565f7ef0038c94c Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Tue, 1 Feb 2022 13:27:41 -0500 Subject: Fixed #33482 -- Fixed QuerySet filtering againts negated Exists() with empty queryset. Thanks Tobias Bengfort for the report. --- tests/expressions/tests.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 5cf9dd1ea5..89c6a7c8de 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1905,6 +1905,13 @@ class ExistsTests(TestCase): ) self.assertNotIn('ORDER BY', captured_sql) + def test_negated_empty_exists(self): + manager = Manager.objects.create() + qs = Manager.objects.filter( + ~Exists(Manager.objects.none()) & Q(pk=manager.pk) + ) + self.assertSequenceEqual(qs, [manager]) + class FieldTransformTests(TestCase): -- cgit v1.3