1
0
mirror of https://github.com/django/django.git synced 2024-12-25 18:46:22 +00:00

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
This commit is contained in:
Malcolm Tredinnick 2008-07-27 18:38:56 +00:00
parent 156b21a339
commit 2c6d1e8ebc

View File

@ -197,14 +197,18 @@ class Query(object):
Returns an iterator over the results from executing this query. Returns an iterator over the results from executing this query.
""" """
resolve_columns = hasattr(self, 'resolve_columns') resolve_columns = hasattr(self, 'resolve_columns')
if resolve_columns: fields = None
if self.select_fields:
fields = self.select_fields + self.related_select_fields
else:
fields = self.model._meta.fields
for rows in self.execute_sql(MULTI): for rows in self.execute_sql(MULTI):
for row in rows: for row in rows:
if resolve_columns: 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) row = self.resolve_columns(row, fields)
yield row yield row