diff options
author | Boulder Sprinters <boulder-sprinters@djangoproject.com> | 2007-03-28 22:20:22 +0000 |
---|---|---|
committer | Boulder Sprinters <boulder-sprinters@djangoproject.com> | 2007-03-28 22:20:22 +0000 |
commit | 9649bfd4f9d1c77df030f407e9d4c3849c0b5ffe (patch) | |
tree | 8036fca4d080b1a996b61bc246e0e0744934efe2 | |
parent | 1f3fc7bc9f8fca6b19b4b88852e5fce5f3dcf347 (diff) | |
download | django-9649bfd4f9d1c77df030f407e9d4c3849c0b5ffe.tar.gz |
boulder-oracle-sprint: Fixed #3820. See #3835 too, as this is a more
correct fix for the same issue (CursorDebugWrapper not iterable).
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4843 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r-- | django/db/backends/oracle/base.py | 28 | ||||
-rw-r--r-- | django/db/backends/oracle/introspection.py | 8 | ||||
-rw-r--r-- | django/db/backends/util.py | 3 |
3 files changed, 21 insertions, 18 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index e220c08ddf..f39701dcd6 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -45,7 +45,7 @@ class DatabaseWrapper(local): self.connection = Database.connect(conn_string, **self.options) cursor = FormatStylePlaceholderCursor(self.connection) # default arraysize of 1 is highly sub-optimal - cursor.arraysize = 256 + cursor.arraysize = 100 # set oracle date to ansi date format cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'") cursor.execute("ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF'") @@ -233,7 +233,7 @@ def get_query_set_class(DefaultQuerySet): "Create a custom QuerySet class for Oracle." from django.db import backend, connection - from django.db.models.query import EmptyResultSet + from django.db.models.query import EmptyResultSet, GET_ITERATOR_CHUNK_SIZE class OracleQuerySet(DefaultQuerySet): @@ -285,15 +285,21 @@ def get_query_set_class(DefaultQuerySet): else: yield field - for unresolved_row in cursor: - row = list(resolve_cols(unresolved_row)) - if fill_cache: - obj, index_end = get_cached_row(self.model, row, 0) - else: - obj = self.model(*row[:index_end]) - for i, k in enumerate(extra_select): - setattr(obj, k[0], row[index_end+i]) - yield obj + while 1: + rows = cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE) + if not rows: + raise StopIteration + for row in rows: + row = list(resolve_cols(row)) + if fill_cache: + obj, index_end = get_cached_row(klass=self.model, row=row, + index_start=0, max_depth=self._max_related_depth) + else: + obj = self.model(*row[:index_end]) + for i, k in enumerate(extra_select): + setattr(obj, k[0], row[index_end+i]) + yield obj + def _get_sql_clause(self, get_full_query=False): from django.db.models.query import fill_table_cache, \ diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py index 02479e71e1..0f5713f36e 100644 --- a/django/db/backends/oracle/introspection.py +++ b/django/db/backends/oracle/introspection.py @@ -6,13 +6,13 @@ foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REF def get_table_list(cursor): "Returns a list of table names in the current database." cursor.execute("SELECT TABLE_NAME FROM USER_TABLES") - return [row[0].upper() for row in cursor] + return [row[0].upper() for row in cursor.fetchall()] def get_table_description(cursor, table_name): "Returns a description of the table, with the DB-API cursor.description interface." cursor.execute("SELECT * FROM %s WHERE ROWNUM < 2" % quote_name(table_name)) return cursor.description - + def _name_to_index(cursor, table_name): """ Returns a dictionary of {field_name: field_index} for the given table. @@ -24,7 +24,7 @@ def get_relations(cursor, table_name): """ Returns a dictionary of {field_index: (field_index_other_table, other_table)} representing all relationships to the given table. Indexes are 0-based. - """ + """ cursor.execute(""" SELECT ta.column_id - 1, tb.table_name, tb.column_id - 1 FROM user_constraints, USER_CONS_COLUMNS ca, USER_CONS_COLUMNS cb, @@ -83,7 +83,7 @@ WHERE allcols.column_name = primarycols.column_name (+) AND # Here, we skip any indexes across multiple fields. indexes[row[0]] = {'primary_key': row[1], 'unique': row[2]} return indexes - + # Maps type codes to Django Field types. DATA_TYPES_REVERSE = { diff --git a/django/db/backends/util.py b/django/db/backends/util.py index 18e2528075..d9489d63da 100644 --- a/django/db/backends/util.py +++ b/django/db/backends/util.py @@ -33,9 +33,6 @@ class CursorDebugWrapper(object): 'time': "%.3f" % (stop - start), }) - def __iter__(self): - return self.cursor.__iter__() - def __getattr__(self, attr): if self.__dict__.has_key(attr): return self.__dict__[attr] |