diff --git a/django/db/models/aggregates.py b/django/db/models/aggregates.py index dfae09e34f..5329cb3396 100644 --- a/django/db/models/aggregates.py +++ b/django/db/models/aggregates.py @@ -24,7 +24,6 @@ class Aggregate(Func): before_resolved = self.get_source_expressions()[index] name = before_resolved.name if hasattr(before_resolved, 'name') else repr(before_resolved) raise FieldError("Cannot compute %s('%s'): '%s' is an aggregate" % (c.name, name, name)) - c._patch_aggregate(query) # backward-compatibility support return c @property @@ -41,37 +40,6 @@ class Aggregate(Func): def get_group_by_cols(self): return [] - def _patch_aggregate(self, query): - """ - Helper method for patching 3rd party aggregates that do not yet support - the new way of subclassing. This method will be removed in Django 1.10. - - add_to_query(query, alias, col, source, is_summary) will be defined on - legacy aggregates which, in turn, instantiates the SQL implementation of - the aggregate. In all the cases found, the general implementation of - add_to_query looks like: - - def add_to_query(self, query, alias, col, source, is_summary): - klass = SQLImplementationAggregate - aggregate = klass(col, source=source, is_summary=is_summary, **self.extra) - query.aggregates[alias] = aggregate - - By supplying a known alias, we can get the SQLAggregate out of the - aggregates dict, and use the sql_function and sql_template attributes - to patch *this* aggregate. - """ - if not hasattr(self, 'add_to_query') or self.function is not None: - return - - placeholder_alias = "_XXXXXXXX_" - self.add_to_query(query, placeholder_alias, None, None, None) - sql_aggregate = query.aggregates.pop(placeholder_alias) - if 'sql_function' not in self.extra and hasattr(sql_aggregate, 'sql_function'): - self.extra['function'] = sql_aggregate.sql_function - - if hasattr(sql_aggregate, 'sql_template'): - self.extra['template'] = sql_aggregate.sql_template - class Avg(Aggregate): function = 'AVG'