Ticket #13349: django-raw-cursor.diff

File django-raw-cursor.diff, 821 bytes (added by Alex Gaynor, 15 years ago)
  • django/db/models/sql/query.py

    diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
    index dc45576..cfe5d37 100644
    a b class RawQuery(object):  
    7171        # Always execute a new query for a new iterator.
    7272        # This could be optimized with a cache at the expense of RAM.
    7373        self._execute_query()
    74         return iter(self.cursor)
     74        if not connections[self.using].features.can_use_chunked_reads:
     75            # If the database can't use chunked reads we need to make sure we
     76            # evaluate the entire query up front.
     77            result = list(self.cursor)
     78        else:
     79            result = self.cursor
     80        return iter(result)
    7581
    7682    def __repr__(self):
    7783        return "<RawQuery: %r>" % (self.sql % self.params)
Back to Top