OrderedDict creation avoidance for .values() queries

Avoid accessing query.extra and query.aggregates directly for .values()
queries. Refs #20950.
This commit is contained in:
Anssi Kääriäinen 2013-10-01 10:56:13 +03:00
parent 4372718e83
commit d64060a736
1 changed files with 2 additions and 2 deletions

View File

@ -1082,7 +1082,7 @@ class ValuesQuerySet(QuerySet):
if self._fields: if self._fields:
self.extra_names = [] self.extra_names = []
self.aggregate_names = [] self.aggregate_names = []
if not self.query.extra and not self.query.aggregates: if not self.query._extra and not self.query._aggregates:
# Short cut - if there are no extra or aggregates, then # Short cut - if there are no extra or aggregates, then
# the values() clause must be just field names. # the values() clause must be just field names.
self.field_names = list(self._fields) self.field_names = list(self._fields)
@ -1093,7 +1093,7 @@ class ValuesQuerySet(QuerySet):
# we inspect the full extra_select list since we might # we inspect the full extra_select list since we might
# be adding back an extra select item that we hadn't # be adding back an extra select item that we hadn't
# had selected previously. # had selected previously.
if f in self.query.extra: if self.query._extra and f in self.query._extra:
self.extra_names.append(f) self.extra_names.append(f)
elif f in self.query.aggregate_select: elif f in self.query.aggregate_select:
self.aggregate_names.append(f) self.aggregate_names.append(f)