Skip to content
Browse files

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: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 2faa3ac commit 442ee687df8eaa402f5ab8475a2b07c18188aba9 @freakboy3742 freakboy3742 committed
Showing with 7 additions and 1 deletion.
  1. +7 −1 django/db/models/sql/
8 django/db/models/sql/
@@ -71,7 +71,13 @@ def __iter__(self):
# Always execute a new query for a new iterator.
# This could be optimized with a cache at the expense of RAM.
- 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 "<RawQuery: %r>" % (self.sql % self.params)

0 comments on commit 442ee68

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