From ea596a52d9f905596cc5335930c8f2ac4511204c Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Wed, 4 Oct 2023 15:30:50 -0400 Subject: Refs #33482 -- Fixed QuerySet selecting and filtering againts Exists() with empty queryset. Thanks Tobias Bengfort for the report. --- tests/expressions/tests.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index f26a6275ea..073e2e9258 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -2294,6 +2294,14 @@ class ExistsTests(TestCase): self.assertSequenceEqual(qs, [manager]) self.assertIs(qs.get().not_exists, True) + def test_filter_by_empty_exists(self): + manager = Manager.objects.create() + qs = Manager.objects.annotate(exists=Exists(Manager.objects.none())).filter( + pk=manager.pk, exists=False + ) + self.assertSequenceEqual(qs, [manager]) + self.assertIs(qs.get().exists, False) + class FieldTransformTests(TestCase): @classmethod -- cgit v1.3