diff options
| author | Brian Rosner <brosner@gmail.com> | 2008-07-16 21:12:43 +0000 |
|---|---|---|
| committer | Brian Rosner <brosner@gmail.com> | 2008-07-16 21:12:43 +0000 |
| commit | dce7cfee16094cb1dd060fb4d90ab73f62069317 (patch) | |
| tree | 62b8191e484bb225258c66687581763383c94b3b /django/db | |
| parent | c546b55a9898861b8aed20d5c0ba6da16f7b22dd (diff) | |
newforms-admin: Merged from trunk up to [7928].
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7937 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/backends/__init__.py | 1 | ||||
| -rw-r--r-- | django/db/backends/sqlite3/base.py | 5 | ||||
| -rw-r--r-- | django/db/models/sql/query.py | 10 |
3 files changed, 14 insertions, 2 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index c5a0eb71fa..899a779673 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -53,6 +53,7 @@ class BaseDatabaseFeatures(object): time_field_needs_date = False interprets_empty_strings_as_nulls = False date_field_supports_time_value = True + can_use_chunked_reads = True class BaseDatabaseOperations(object): """ diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index b8bf5c8f0b..5cb21f5e3b 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -40,6 +40,11 @@ Database.register_adapter(decimal.Decimal, util.rev_typecast_decimal) class DatabaseFeatures(BaseDatabaseFeatures): supports_constraints = False + # SQLite cannot handle us only partially reading from a cursor's result set + # and then writing the same rows to the database in another cursor. This + # setting ensures we always read result sets fully into memory all in one + # go. + can_use_chunked_reads = False class DatabaseOperations(BaseDatabaseOperations): def date_extract_sql(self, lookup_type, field_name): diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index f682c71d07..ef69d7657f 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1616,10 +1616,16 @@ class Query(object): # The MULTI case. if self.ordering_aliases: - return order_modified_iter(cursor, len(self.ordering_aliases), + result = order_modified_iter(cursor, len(self.ordering_aliases), self.connection.features.empty_fetchmany_value) - return iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)), + result = iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)), self.connection.features.empty_fetchmany_value) + if not self.connection.features.can_use_chunked_reads: + # If we are using non-chunked reads, we return the same data + # structure as normally, but ensure it is all read into memory + # before going any further. + return list(result) + return result # Use the backend's custom Query class if it defines one. Otherwise, use the # default. |
