diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-03-18 06:15:29 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-03-18 06:15:29 +0000 |
| commit | 98b5667a06bcf47c8103bc4b1a502e3d00f3c3c6 (patch) | |
| tree | 915297c3e26ae64bcbb41ec1bb0d45891fb0a54d | |
| parent | 6b974720a916dd014a5aff22bbd2349e47d6ec6c (diff) | |
queryset-refactor: Different database backends return different empty sequences
when fetchmany() is exhausted. This change allows for that. Fixed #6807.
Nice debugging from tpherndon.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7283 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/db/backends/__init__.py | 1 | ||||
| -rw-r--r-- | django/db/backends/mysql/base.py | 1 | ||||
| -rw-r--r-- | django/db/backends/mysql_old/base.py | 1 | ||||
| -rw-r--r-- | django/db/models/sql/query.py | 3 |
4 files changed, 5 insertions, 1 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 6ba06f083a..fdbd8f7885 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -50,6 +50,7 @@ class BaseDatabaseFeatures(object): supports_tablespaces = False uses_case_insensitive_names = False uses_custom_queryset = False + empty_fetchmany_value = [] class BaseDatabaseOperations(object): """ diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index c2b2c7ab1c..cfc07d6008 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -61,6 +61,7 @@ server_version_re = re.compile(r'(\d{1,2})\.(\d{1,2})\.(\d{1,2})') class DatabaseFeatures(BaseDatabaseFeatures): autoindexes_primary_keys = False inline_fk_references = False + empty_fetchmany_value = () class DatabaseOperations(BaseDatabaseOperations): def date_extract_sql(self, lookup_type, field_name): diff --git a/django/db/backends/mysql_old/base.py b/django/db/backends/mysql_old/base.py index 374e9af1f5..efbfeeafc5 100644 --- a/django/db/backends/mysql_old/base.py +++ b/django/db/backends/mysql_old/base.py @@ -66,6 +66,7 @@ class MysqlDebugWrapper: class DatabaseFeatures(BaseDatabaseFeatures): autoindexes_primary_keys = False inline_fk_references = False + empty_fetchmany_value = () 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 384ff140a9..771ee55e12 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1330,7 +1330,8 @@ class Query(object): if result_type == SINGLE: return cursor.fetchone() # The MULTI case. - return iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)), []) + return iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)), + self.connection.features.empty_fetchmany_value) def get_order_dir(field, default='ASC'): """ |
