summaryrefslogtreecommitdiff
path: root/django/db/models/query_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/query_utils.py')
-rw-r--r--django/db/models/query_utils.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
index 9e4ddfec58..7751f988db 100644
--- a/django/db/models/query_utils.py
+++ b/django/db/models/query_utils.py
@@ -90,22 +90,24 @@ class Q(tree.Node):
clause, _ = query._add_q(self, reuse, allow_joins=allow_joins)
return clause
- def refs_aggregate(self, existing_aggregates):
- def _refs_aggregate(obj, existing_aggregates):
- if not isinstance(obj, tree.Node):
- aggregate, aggregate_lookups = refs_aggregate(obj[0].split(LOOKUP_SEP), existing_aggregates)
- if not aggregate and hasattr(obj[1], 'refs_aggregate'):
- return obj[1].refs_aggregate(existing_aggregates)
+ @classmethod
+ def _refs_aggregate(cls, obj, existing_aggregates):
+ if not isinstance(obj, tree.Node):
+ aggregate, aggregate_lookups = refs_aggregate(obj[0].split(LOOKUP_SEP), existing_aggregates)
+ if not aggregate and hasattr(obj[1], 'refs_aggregate'):
+ return obj[1].refs_aggregate(existing_aggregates)
+ return aggregate, aggregate_lookups
+ for c in obj.children:
+ aggregate, aggregate_lookups = cls._refs_aggregate(c, existing_aggregates)
+ if aggregate:
return aggregate, aggregate_lookups
- for c in obj.children:
- aggregate, aggregate_lookups = _refs_aggregate(c, existing_aggregates)
- if aggregate:
- return aggregate, aggregate_lookups
- return False, ()
+ return False, ()
+ def refs_aggregate(self, existing_aggregates):
if not existing_aggregates:
return False
- return _refs_aggregate(self, existing_aggregates)
+
+ return self._refs_aggregate(self, existing_aggregates)
class DeferredAttribute(object):