Ticket #7256: extra_values.diff

File extra_values.diff, 1.3 KB (added by Nicolas Lara, 16 years ago)
  • django/db/models/query.py

     
    513513        # names of the model fields to select.
    514514
    515515    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)
    517519        names = self.query.extra_select.keys() + self.field_names
    518520        for row in self.query.results_iter():
    519521            yield dict(zip(names, row))
  • tests/regressiontests/queries/models.py

     
    507507>>> [sorted(d.items()) for d in dicts]
    508508[[('id', 1), ('rank', 2)], [('id', 2), ('rank', 1)], [('id', 3), ('rank', 3)]]
    509509
     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
    510514Bugs #2874, #3002
    511515>>> qs = Item.objects.select_related().order_by('note__note', 'name')
    512516>>> list(qs)
Back to Top