summaryrefslogtreecommitdiff
path: root/tests/lookup
diff options
context:
space:
mode:
authorSimon Charette <simon.charette@zapier.com>2019-08-11 19:42:27 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-08-12 09:39:26 +0200
commitf7e9db14bbd39a393260d0a8b44aae80cbb65c81 (patch)
treedb43cdb1a04ec1c9a930c064702fa822be870ea1 /tests/lookup
parent088a6fab1ccd1efcd4ce28b353df3c03dcfa0caf (diff)
downloaddjango-f7e9db14bbd39a393260d0a8b44aae80cbb65c81.tar.gz
Refs #25367 -- Added test for Exists() lookup rhs.
Diffstat (limited to 'tests/lookup')
-rw-r--r--tests/lookup/tests.py10
1 files changed, 10 insertions, 0 deletions
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())