Ticket #14930: extra_order_by_values_list-17428.2.diff
File extra_order_by_values_list-17428.2.diff, 1.3 KB (added by , 13 years ago) |
---|
-
django/db/models/query.py
981 981 self.extra_names = None 982 982 self.field_names = [f.attname for f in self.model._meta.fields] 983 983 self.aggregate_names = None 984 984 985 985 self.query.select = [] 986 if self.extra_names is not None: 987 self.query.set_extra_mask(self.extra_names) 986 extra_mask_names = self.extra_names + list(self.query.extra_order_by or []) 987 if extra_mask_names is not None: 988 self.query.set_extra_mask(extra_mask_names) 988 989 self.query.add_fields(self.field_names, True) 989 990 if self.aggregate_names is not None: 990 991 self.query.set_aggregate_mask(self.aggregate_names) … … 1059 1060 def iterator(self): 1060 1061 if self.flat and len(self._fields) == 1: 1061 1062 for row in self.query.get_compiler(self.db).results_iter(): 1062 yield row[ 0]1063 yield row[len(self.query.extra_select_mask)] 1063 1064 elif not self.query.extra_select and not self.query.aggregate_select: 1064 1065 for row in self.query.get_compiler(self.db).results_iter(): 1065 1066 yield tuple(row)