mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #31607 -- Fixed evaluated Subquery equality.
Regression in 691def10a0
.
This commit is contained in:
parent
b739f2e91d
commit
a125da6a7c
2 changed files with 27 additions and 1 deletions
|
@ -511,6 +511,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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue