mirror of https://github.com/django/django.git
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().
This commit is contained in:
parent
7dfe03f86d
commit
160969d970
|
@ -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'))
|
||||
|
|
Loading…
Reference in New Issue