Ticket #7256: extra_values.diff
File extra_values.diff, 1.3 KB (added by , 16 years ago) |
---|
-
django/db/models/query.py
513 513 # names of the model fields to select. 514 514 515 515 def iterator(self): 516 self.query.trim_extra_select(self.extra_names) 516 if (not self.extra_names and 517 len(self.field_names) != len(self.model._meta.fields)): 518 self.query.trim_extra_select(self.extra_names) 517 519 names = self.query.extra_select.keys() + self.field_names 518 520 for row in self.query.results_iter(): 519 521 yield dict(zip(names, row)) -
tests/regressiontests/queries/models.py
507 507 >>> [sorted(d.items()) for d in dicts] 508 508 [[('id', 1), ('rank', 2)], [('id', 2), ('rank', 1)], [('id', 3), ('rank', 3)]] 509 509 510 # But an empty values() call includes all aliases. 511 >>> qs.values().order_by('id') 512 [{'author_id': 2, 'good': 0, 'id': 1, 'rank': 2}, {'author_id': 3, 'good': 0, 'id': 2, 'rank': 1}, {'author_id': 1, 'good': 1, 'id': 3, 'rank': 3}] 513 510 514 Bugs #2874, #3002 511 515 >>> qs = Item.objects.select_related().order_by('note__note', 'name') 512 516 >>> list(qs)