Changeset 7926
- Timestamp:
- 07/15/08 13:47:32 (4 months ago)
- Files:
-
- django/trunk/django/db/backends/__init__.py (modified) (1 diff)
- django/trunk/django/db/backends/sqlite3/base.py (modified) (1 diff)
- django/trunk/django/db/models/sql/query.py (modified) (1 diff)
- django/trunk/tests/regressiontests/queries/models.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/db/backends/__init__.py
r7852 r7926 54 54 interprets_empty_strings_as_nulls = False 55 55 date_field_supports_time_value = True 56 can_use_chunked_reads = True 56 57 57 58 class BaseDatabaseOperations(object): django/trunk/django/db/backends/sqlite3/base.py
r7477 r7926 41 41 class DatabaseFeatures(BaseDatabaseFeatures): 42 42 supports_constraints = False 43 # SQLite cannot handle us only partially reading from a cursor's result set 44 # and then writing the same rows to the database in another cursor. This 45 # setting ensures we always read result sets fully into memory all in one 46 # go. 47 can_use_chunked_reads = False 43 48 44 49 class DatabaseOperations(BaseDatabaseOperations): django/trunk/django/db/models/sql/query.py
r7901 r7926 1617 1617 # The MULTI case. 1618 1618 if self.ordering_aliases: 1619 re turnorder_modified_iter(cursor, len(self.ordering_aliases),1619 result = order_modified_iter(cursor, len(self.ordering_aliases), 1620 1620 self.connection.features.empty_fetchmany_value) 1621 re turniter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)),1621 result = iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)), 1622 1622 self.connection.features.empty_fetchmany_value) 1623 if not self.connection.features.can_use_chunked_reads: 1624 # If we are using non-chunked reads, we return the same data 1625 # structure as normally, but ensure it is all read into memory 1626 # before going any further. 1627 return list(result) 1628 return result 1623 1629 1624 1630 # Use the backend's custom Query class if it defines one. Otherwise, use the django/trunk/tests/regressiontests/queries/models.py
r7914 r7926 7 7 8 8 from django.db import models 9 from django.db.models.query import Q 9 from django.db.models.query import Q, ITER_CHUNK_SIZE 10 10 11 11 # Python 2.3 doesn't have sorted() … … 14 14 except NameError: 15 15 from django.utils.itercompat import sorted 16 16 17 17 class Tag(models.Model): 18 18 name = models.CharField(max_length=10) … … 821 821 [] 822 822 823 Bug #7411 - saving to db must work even with partially read result set in 824 another cursor. 825 826 >>> for num in range(2 * ITER_CHUNK_SIZE + 1): 827 ... _ = Number.objects.create(num=num) 828 829 >>> for i, obj in enumerate(Number.objects.all()): 830 ... obj.save() 831 ... if i > 10: break 832 823 833 """} 824 834
