Skip to content

Commit f7e9db1

Browse files
charettesfelixxm
authored andcommitted
Refs #25367 -- Added test for Exists() lookup rhs.
1 parent 088a6fa commit f7e9db1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/lookup/tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from django.core.exceptions import FieldError
77
from django.db import connection
8+
from django.db.models.expressions import Exists, OuterRef
89
from django.db.models.functions import Substr
910
from django.test import TestCase, skipUnlessDBFeature
1011

@@ -932,3 +933,12 @@ def test_custom_lookup_none_rhs(self):
932933
field = query.model._meta.get_field('nulled_text_field')
933934
self.assertIsInstance(query.build_lookup(['isnull_none_rhs'], field, None), IsNullWithNoneAsRHS)
934935
self.assertTrue(Season.objects.filter(pk=season.pk, nulled_text_field__isnull_none_rhs=True))
936+
937+
def test_exact_exists(self):
938+
qs = Article.objects.filter(pk=OuterRef('pk'))
939+
seasons = Season.objects.annotate(
940+
pk_exists=Exists(qs),
941+
).filter(
942+
pk_exists=Exists(qs),
943+
)
944+
self.assertCountEqual(seasons, Season.objects.all())

0 commit comments

Comments
 (0)