Ticket #31607: test-31607.diff

File test-31607.diff, 1.2 KB (added by Mariusz Felisiak, 4 years ago)

Regression test.

  • tests/expressions/tests.py

    diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
    index b17a286d5d..6bcb4bcbc6 100644
    a b class BasicExpressionsTests(TestCase):  
    511511            Employee.objects.exclude(company_point_of_contact_set=None).values('pk')
    512512        )
    513513
     514    def test_subquery_eq(self):
     515        qs = Employee.objects.annotate(
     516            is_ceo=Exists(Company.objects.filter(ceo=OuterRef('pk'))),
     517            is_point_of_contact=Exists(
     518                Company.objects.filter(point_of_contact=OuterRef('pk')),
     519            ),
     520            is_ceo_2=Exists(Company.objects.filter(ceo=OuterRef('pk'))),
     521        ).filter(is_ceo=True, is_point_of_contact=False, firstname='Joe')
     522        self.assertEqual(
     523            qs.query.annotations['is_ceo'],
     524            qs.query.annotations['is_ceo_2'],
     525        )
     526        self.assertNotEqual(
     527            qs.query.annotations['is_ceo'],
     528            qs.query.annotations['is_point_of_contact'],
     529        )
     530
    514531    def test_in_subquery(self):
    515532        # This is a contrived test (and you really wouldn't write this query),
    516533        # but it is a succinct way to test the __in=Subquery() construct.
Back to Top