From 160969d97080b53e9113cadcecc27c26a51881e8 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Thu, 13 Jul 2017 02:46:44 -0400 Subject: [PATCH] Refs #24887 -- Stopped mutating a test expression during as_sql(). Also defined an explicit output_field as it was mixing an expression with an IntegerField() with one with a DecimalField(). --- tests/aggregation/tests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index 3c53877303..c45cb8fc33 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1099,9 +1099,12 @@ class AggregateTestCase(TestCase): def test_multi_arg_aggregate(self): class MyMax(Max): + output_field = DecimalField() + def as_sql(self, compiler, connection): - self.set_source_expressions(self.get_source_expressions()[0:1]) - return super().as_sql(compiler, connection) + copy = self.copy() + copy.set_source_expressions(copy.get_source_expressions()[0:1]) + return super(MyMax, copy).as_sql(compiler, connection) with self.assertRaisesMessage(TypeError, 'Complex aggregates require an alias'): Book.objects.aggregate(MyMax('pages', 'price'))