diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2020-07-01 14:01:46 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-01 11:01:46 +0200 |
| commit | ed6b14d4591e536985222b61cb8b83908d58140d (patch) | |
| tree | 0b4cca11ebc8998600b049278dd0dd317a8f2940 /tests | |
| parent | dbae6de01e7cea8d2a7c208213dbb8bffc27ded1 (diff) | |
Refs #28621 -- Fixed crash of annotations with nested OuterRef.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/expressions/tests.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index ed87d99fd5..72f95f0194 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -710,6 +710,22 @@ class BasicExpressionsTests(TestCase): ).get(pk=self.gmbh.pk) self.assertEqual(gmbh_salary.max_ceo_salary_raise, 2332) + def test_annotation_with_nested_outerref(self): + self.gmbh.point_of_contact = Employee.objects.get(lastname='Meyer') + self.gmbh.save() + inner = Employee.objects.annotate( + outer_lastname=OuterRef(OuterRef('lastname')), + ).filter(lastname__startswith=Left('outer_lastname', 1)) + qs = Employee.objects.annotate( + ceo_company=Subquery( + Company.objects.filter( + point_of_contact__in=inner, + ceo__pk=OuterRef('pk'), + ).values('name'), + ), + ).filter(ceo_company__isnull=False) + self.assertEqual(qs.get().ceo_company, 'Test GmbH') + def test_pickle_expression(self): expr = Value(1, output_field=IntegerField()) expr.convert_value # populate cached property |
