summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-19 12:30:49 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-19 22:51:01 +0200
commit0ba5aadb3377e49e995753944a7e5e55c3840bed (patch)
tree3f09a8b8e421100628e14b1608e36521ad50ec52 /tests
parent92acf1022fb13a7a8b1ff7cdfe72c21050c1e4e7 (diff)
downloaddjango-0ba5aadb3377e49e995753944a7e5e55c3840bed.tar.gz
[3.0.x] Fixed #31607 -- Fixed evaluated Subquery equality.
Regression in 691def10a0197d83d2d108bd9043b0916d0f09b4. Backport of a125da6a7c79b1d4c55677d0bed6f9b1d7d77353 from master
Diffstat (limited to 'tests')
-rw-r--r--tests/expressions/tests.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
index 66e19291b2..58682afd82 100644
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -512,6 +512,25 @@ class BasicExpressionsTests(TestCase):
Employee.objects.exclude(company_point_of_contact_set=None).values('pk')
)
+ def test_subquery_eq(self):
+ qs = Employee.objects.annotate(
+ is_ceo=Exists(Company.objects.filter(ceo=OuterRef('pk'))),
+ is_point_of_contact=Exists(
+ Company.objects.filter(point_of_contact=OuterRef('pk')),
+ ),
+ small_company=Exists(
+ queryset=Company.objects.filter(num_employees__lt=200),
+ ),
+ ).filter(is_ceo=True, is_point_of_contact=False, small_company=True)
+ self.assertNotEqual(
+ qs.query.annotations['is_ceo'],
+ qs.query.annotations['is_point_of_contact'],
+ )
+ self.assertNotEqual(
+ qs.query.annotations['is_ceo'],
+ qs.query.annotations['small_company'],
+ )
+
def test_in_subquery(self):
# This is a contrived test (and you really wouldn't write this query),
# but it is a succinct way to test the __in=Subquery() construct.