diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py index 5629515a59..7bf436ad7a 100644 --- a/tests/lookup/tests.py +++ b/tests/lookup/tests.py @@ -5,6 +5,7 @@ from operator import attrgetter from django.core.exceptions import FieldError from django.db import connection +from django.db.models.expressions import Exists, OuterRef from django.db.models.functions import Substr from django.test import TestCase, skipUnlessDBFeature @@ -932,3 +933,12 @@ class LookupTests(TestCase): field = query.model._meta.get_field('nulled_text_field') self.assertIsInstance(query.build_lookup(['isnull_none_rhs'], field, None), IsNullWithNoneAsRHS) self.assertTrue(Season.objects.filter(pk=season.pk, nulled_text_field__isnull_none_rhs=True)) + + def test_exact_exists(self): + qs = Article.objects.filter(pk=OuterRef('pk')) + seasons = Season.objects.annotate( + pk_exists=Exists(qs), + ).filter( + pk_exists=Exists(qs), + ) + self.assertCountEqual(seasons, Season.objects.all())