Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #7886 -- Reordered some code in Query.results_iter() to ensure …

…that all

the prequisites are correctly initialised prior to using them. Only affects
Oracle and other db backends requiring resolve_columns() (e.g. MS SQL?)


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8112 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2c6d1e8ebc2d5d8cb62473dcb35f3c783aab6b95 1 parent 156b21a
Malcolm Tredinnick malcolmt authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 django/db/models/sql/query.py
14 django/db/models/sql/query.py
View
@@ -197,14 +197,18 @@ def results_iter(self):
Returns an iterator over the results from executing this query.
"""
resolve_columns = hasattr(self, 'resolve_columns')
- if resolve_columns:
- if self.select_fields:
- fields = self.select_fields + self.related_select_fields
- else:
- fields = self.model._meta.fields
+ fields = None
for rows in self.execute_sql(MULTI):
for row in rows:
if resolve_columns:
+ if fields is None:
+ # We only set this up here because
+ # related_select_fields isn't populated until
+ # execute_sql() has been called.
+ if self.select_fields:
+ fields = self.select_fields + self.related_select_fields
+ else:
+ fields = self.model._meta.fields
row = self.resolve_columns(row, fields)
yield row
Please sign in to comment.
Something went wrong with that request. Please try again.