diff options
| author | Oliver Sauder <sliverc@users.noreply.github.com> | 2018-02-21 03:58:43 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-02-20 21:58:43 -0500 |
| commit | 6f0b8c1c9ef30a1f41ce401e1fed2effd524fed1 (patch) | |
| tree | 7aef7cce3e97f4c86c6cbee9c86fee2cc38abb89 /tests | |
| parent | e8e0cfa9e550a3309a795ef133e59b90302813c8 (diff) | |
Fixed #28442 -- Fixed crash with nested OuterRefs that reference AutoField.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/expressions/tests.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 2980d750c8..561a8e3563 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -530,6 +530,16 @@ class BasicExpressionsTests(TestCase): # This is a contrived example. It exercises the double OuterRef form. self.assertCountEqual(outer, [first, second, third]) + def test_nested_subquery_outer_ref_with_autofield(self): + first = Time.objects.create(time='09:00') + second = Time.objects.create(time='17:00') + SimulationRun.objects.create(start=first, end=second, midpoint='12:00') + inner = SimulationRun.objects.filter(start=OuterRef(OuterRef('pk'))).values('start') + middle = Time.objects.annotate(other=Subquery(inner)).values('other')[:1] + outer = Time.objects.annotate(other=Subquery(middle, output_field=models.IntegerField())) + # This exercises the double OuterRef form with AutoField as pk. + self.assertCountEqual(outer, [first, second]) + def test_annotations_within_subquery(self): Company.objects.filter(num_employees__lt=50).update(ceo=Employee.objects.get(firstname='Frank')) inner = Company.objects.filter( |
