mirror of
				https://github.com/django/django.git
				synced 2025-10-30 09:06:13 +00:00 
			
		
		
		
	OrderedDict creation avoidance for .values() queries
Avoid accessing query.extra and query.aggregates directly for .values() queries. Refs #20950.
This commit is contained in:
		| @@ -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) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user