From 442ee687df8eaa402f5ab8475a2b07c18188aba9 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 15 Apr 2010 13:01:51 +0000 Subject: [PATCH] Fixed #13349 -- Ensure that raw queries evaluate the entire query if the backend doesn't support chunked reads. Thanks to Alex Gaynor for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12978 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/sql/query.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index dc455763be..cfe5d37a37 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -71,7 +71,13 @@ class RawQuery(object): # Always execute a new query for a new iterator. # This could be optimized with a cache at the expense of RAM. self._execute_query() - return iter(self.cursor) + if not connections[self.using].features.can_use_chunked_reads: + # If the database can't use chunked reads we need to make sure we + # evaluate the entire query up front. + result = list(self.cursor) + else: + result = self.cursor + return iter(result) def __repr__(self): return "" % (self.sql % self.params)