summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2017-07-13 02:46:44 -0400
committerSimon Charette <charette.s@gmail.com>2017-07-21 00:23:01 -0400
commit160969d97080b53e9113cadcecc27c26a51881e8 (patch)
tree19cff9d0314cd2211bd22ac8c19b577a84315016
parent7dfe03f86d7e44393f9ea85875d6967e05e84ef3 (diff)
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().
-rw-r--r--tests/aggregation/tests.py7
1 files 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'))