diff options
| author | Simon Charette <charette.s@gmail.com> | 2023-10-04 15:30:50 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-10-04 21:32:35 +0200 |
| commit | 458bc9e768ede649e8e540823dd4ec0c6383744b (patch) | |
| tree | 71b4bb133249ac39f95e67040d6eaed362c44db8 /tests | |
| parent | d9ab9dbea6db7f7c8bbb5dc4a1e57e97c278fff9 (diff) | |
[5.0.x] Refs #33482 -- Fixed QuerySet selecting and filtering againts Exists() with empty queryset.
Thanks Tobias Bengfort for the report.
Backport of ea596a52d9f905596cc5335930c8f2ac4511204c from main
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/expressions/tests.py | 8 |
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 |
