mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Removed unused BaseExpression.refs_aggregate().
Unused since afe0bb7b13.
This commit is contained in:
@@ -5,8 +5,7 @@ from django.conf import settings
|
||||
from django.core.exceptions import FieldError
|
||||
from django.db.backends import utils as backend_utils
|
||||
from django.db.models import fields
|
||||
from django.db.models.constants import LOOKUP_SEP
|
||||
from django.db.models.query_utils import Q, refs_aggregate
|
||||
from django.db.models.query_utils import Q
|
||||
from django.utils import six, timezone
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
@@ -306,24 +305,6 @@ class BaseExpression(object):
|
||||
c.copied = True
|
||||
return c
|
||||
|
||||
def refs_aggregate(self, existing_aggregates):
|
||||
"""
|
||||
Does this expression contain a reference to some of the
|
||||
existing aggregates? If so, returns the aggregate and also
|
||||
the lookup parts that *weren't* found. So, if
|
||||
existing_aggregates = {'max_id': Max('id')}
|
||||
self.name = 'max_id'
|
||||
queryset.filter(max_id__range=[10,100])
|
||||
then this method will return Max('id') and those parts of the
|
||||
name that weren't found. In this case `max_id` is found and the range
|
||||
portion is returned as ('range',).
|
||||
"""
|
||||
for node in self.get_source_expressions():
|
||||
agg, lookup = node.refs_aggregate(existing_aggregates)
|
||||
if agg:
|
||||
return agg, lookup
|
||||
return False, ()
|
||||
|
||||
def get_group_by_cols(self):
|
||||
if not self.contains_aggregate:
|
||||
return [self]
|
||||
@@ -482,9 +463,6 @@ class F(Combinable):
|
||||
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
|
||||
return query.resolve_ref(self.name, allow_joins, reuse, summarize)
|
||||
|
||||
def refs_aggregate(self, existing_aggregates):
|
||||
return refs_aggregate(self.name.split(LOOKUP_SEP), existing_aggregates)
|
||||
|
||||
def asc(self):
|
||||
return OrderBy(self)
|
||||
|
||||
|
||||
@@ -93,25 +93,6 @@ class Q(tree.Node):
|
||||
query.promote_joins(joins)
|
||||
return clause
|
||||
|
||||
@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
|
||||
return False, ()
|
||||
|
||||
def refs_aggregate(self, existing_aggregates):
|
||||
if not existing_aggregates:
|
||||
return False
|
||||
|
||||
return self._refs_aggregate(self, existing_aggregates)
|
||||
|
||||
|
||||
class DeferredAttribute(object):
|
||||
"""
|
||||
@@ -301,20 +282,6 @@ def deferred_class_factory(model, attrs):
|
||||
return type(str(name), (model,), overrides)
|
||||
|
||||
|
||||
def refs_aggregate(lookup_parts, aggregates):
|
||||
"""
|
||||
A helper method to check if the lookup_parts contains references
|
||||
to the given aggregates set. Because the LOOKUP_SEP is contained in the
|
||||
default annotation names we must check each prefix of the lookup_parts
|
||||
for a match.
|
||||
"""
|
||||
for n in range(len(lookup_parts) + 1):
|
||||
level_n_lookup = LOOKUP_SEP.join(lookup_parts[0:n])
|
||||
if level_n_lookup in aggregates and aggregates[level_n_lookup].contains_aggregate:
|
||||
return aggregates[level_n_lookup], lookup_parts[n:]
|
||||
return False, ()
|
||||
|
||||
|
||||
def refs_expression(lookup_parts, annotations):
|
||||
"""
|
||||
A helper method to check if the lookup_parts contains references
|
||||
|
||||
Reference in New Issue
Block a user