diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-03-27 08:24:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-27 08:24:05 +0100 |
| commit | 2a431db0f5e91110b4fda05949de1f158a20ec5b (patch) | |
| tree | 5acda0220006047a6b83af583e5d42bca633afc0 /tests | |
| parent | c4447ad231b6ba071a5295192faa41ff6494f14e (diff) | |
Fixed #28621 -- Fixed crash of annotations with OuterRef.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/expressions/tests.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index c19178b3ca..c20b88ff83 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -591,6 +591,17 @@ class BasicExpressionsTests(TestCase): outer = Company.objects.filter(pk__in=Subquery(inner.values('pk'))) self.assertEqual(outer.get().name, 'Test GmbH') + def test_annotation_with_outerref(self): + gmbh_salary = Company.objects.annotate( + max_ceo_salary_raise=Subquery( + Company.objects.annotate( + salary_raise=OuterRef('num_employees') + F('num_employees'), + ).order_by('-salary_raise').values('salary_raise')[:1], + output_field=models.IntegerField(), + ), + ).get(pk=self.gmbh.pk) + self.assertEqual(gmbh_salary.max_ceo_salary_raise, 2332) + def test_pickle_expression(self): expr = Value(1, output_field=models.IntegerField()) expr.convert_value # populate cached property |
