summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-09-24 08:16:54 -0400
committerTim Graham <timograham@gmail.com>2015-09-24 09:15:55 -0400
commita780505f3a3c41b691cf142379b192960c008b50 (patch)
tree4678b328c5a2286d106b5be91d93aff36f870ca5
parentdfa81bb1df81637be333e9a67120a1670703a941 (diff)
Refs #14030 -- Removed more backwards compatiblity for old-style aggregates.
Per deprecation timeline.
-rw-r--r--django/db/models/aggregates.py32
1 files changed, 0 insertions, 32 deletions
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'