mirror of
https://github.com/django/django.git
synced 2025-08-08 12:58:37 +00:00
Replaced inner functions by class methods.
refs #24031 Thanks to Tim Graham and Michał Modzelewski for the review.
This commit is contained in:
parent
4832c004e8
commit
47bdad4e6b
2 changed files with 29 additions and 25 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue