summaryrefslogtreecommitdiff
path: root/tests/expressions
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2023-10-04 15:30:50 -0400
committerGitHub <noreply@github.com>2023-10-04 21:30:50 +0200
commitea596a52d9f905596cc5335930c8f2ac4511204c (patch)
treea2a65ab2441b6191ff08b3769675b03212bf34ce /tests/expressions
parent0989cf13e70f52d5b241aa176eb74a680a282d09 (diff)
Refs #33482 -- Fixed QuerySet selecting and filtering againts Exists() with empty queryset.
Thanks Tobias Bengfort for the report.
Diffstat (limited to 'tests/expressions')
-rw-r--r--tests/expressions/tests.py8
1 files changed, 8 insertions, 0 deletions
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