Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 9649bfd4f9d1c77df030f407e9d4c3849c0b5ffe 1 parent 1f3fc7b
Boulder Sprinters authored
View
28 django/db/backends/oracle/base.py
@@ -45,7 +45,7 @@ def cursor(self):
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 resolve_cols(row):
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, \
View
8 django/db/backends/oracle/introspection.py
@@ -6,13 +6,13 @@
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 @@ def get_indexes(cursor, table_name):
# 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 = {
View
3  django/db/backends/util.py
@@ -33,9 +33,6 @@ def executemany(self, sql, param_list):
'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]

0 comments on commit 9649bfd

Please sign in to comment.
Something went wrong with that request. Please try again.