Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored July 27, 2008

Showing 1 changed file with 9 additions and 5 deletions. Show diff stats Hide diff stats

  1. 14  django/db/models/sql/query.py
14  django/db/models/sql/query.py
@@ -197,14 +197,18 @@ def results_iter(self):
197 197
         Returns an iterator over the results from executing this query.
198 198
         """
199 199
         resolve_columns = hasattr(self, 'resolve_columns')
200  
-        if resolve_columns:
201  
-            if self.select_fields:
202  
-                fields = self.select_fields + self.related_select_fields
203  
-            else:
204  
-                fields = self.model._meta.fields
  200
+        fields = None
205 201
         for rows in self.execute_sql(MULTI):
206 202
             for row in rows:
207 203
                 if resolve_columns:
  204
+                    if fields is None:
  205
+                        # We only set this up here because
  206
+                        # related_select_fields isn't populated until
  207
+                        # execute_sql() has been called.
  208
+                        if self.select_fields:
  209
+                            fields = self.select_fields + self.related_select_fields
  210
+                        else:
  211
+                            fields = self.model._meta.fields
208 212
                     row = self.resolve_columns(row, fields)
209 213
                 yield row
210 214
 

0 notes on commit 2c6d1e8

Please sign in to comment.
Something went wrong with that request. Please try again.