From 29769a9942b08c86397692fa164396a670a4e1ec Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Fri, 7 Jul 2017 09:04:37 +0500 Subject: Fixed #28382 -- Prevented BaseExpression._output_field from being set if _resolve_output_field() fails. --- tests/aggregation/tests.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests/aggregation') diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index c3f7998f60..3c53877303 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -965,8 +965,12 @@ class AggregateTestCase(TestCase): self.assertEqual(p2, {'avg_price': Approximate(53.39, places=2)}) def test_combine_different_types(self): - with self.assertRaisesMessage(FieldError, 'Expression contains mixed types. You must set output_field'): - Book.objects.annotate(sums=Sum('rating') + Sum('pages') + Sum('price')).get(pk=self.b4.pk) + msg = 'Expression contains mixed types. You must set output_field.' + qs = Book.objects.annotate(sums=Sum('rating') + Sum('pages') + Sum('price')) + with self.assertRaisesMessage(FieldError, msg): + qs.first() + with self.assertRaisesMessage(FieldError, msg): + qs.first() b1 = Book.objects.annotate(sums=Sum(F('rating') + F('pages') + F('price'), output_field=IntegerField())).get(pk=self.b4.pk) -- cgit v1.3