Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
authored
28  django/db/backends/oracle/base.py
@@ -45,7 +45,7 @@ def cursor(self):
45 45
                 self.connection = Database.connect(conn_string, **self.options)
46 46
         cursor = FormatStylePlaceholderCursor(self.connection)
47 47
         # default arraysize of 1 is highly sub-optimal
48  
-        cursor.arraysize = 256
  48
+        cursor.arraysize = 100
49 49
         # set oracle date to ansi date format
50 50
         cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'")
51 51
         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):
233 233
     "Create a custom QuerySet class for Oracle."
234 234
 
235 235
     from django.db import backend, connection
236  
-    from django.db.models.query import EmptyResultSet
  236
+    from django.db.models.query import EmptyResultSet, GET_ITERATOR_CHUNK_SIZE
237 237
 
238 238
     class OracleQuerySet(DefaultQuerySet):
239 239
 
@@ -285,15 +285,21 @@ def resolve_cols(row):
285 285
                     else:
286 286
                         yield field
287 287
 
288  
-            for unresolved_row in cursor:
289  
-                row = list(resolve_cols(unresolved_row))
290  
-                if fill_cache:
291  
-                    obj, index_end = get_cached_row(self.model, row, 0)
292  
-                else:
293  
-                    obj = self.model(*row[:index_end])
294  
-                for i, k in enumerate(extra_select):
295  
-                    setattr(obj, k[0], row[index_end+i])
296  
-                yield obj
  288
+            while 1:
  289
+                rows = cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)
  290
+                if not rows:
  291
+                    raise StopIteration
  292
+                for row in rows:
  293
+                    row = list(resolve_cols(row))
  294
+                    if fill_cache:
  295
+                        obj, index_end = get_cached_row(klass=self.model, row=row,
  296
+                                                        index_start=0, max_depth=self._max_related_depth)
  297
+                    else:
  298
+                        obj = self.model(*row[:index_end])
  299
+                    for i, k in enumerate(extra_select):
  300
+                        setattr(obj, k[0], row[index_end+i])
  301
+                    yield obj
  302
+
297 303
 
298 304
         def _get_sql_clause(self, get_full_query=False):
299 305
             from django.db.models.query import fill_table_cache, \
8  django/db/backends/oracle/introspection.py
@@ -6,13 +6,13 @@
6 6
 def get_table_list(cursor):
7 7
     "Returns a list of table names in the current database."
8 8
     cursor.execute("SELECT TABLE_NAME FROM USER_TABLES")
9  
-    return [row[0].upper() for row in cursor]
  9
+    return [row[0].upper() for row in cursor.fetchall()]
10 10
 
11 11
 def get_table_description(cursor, table_name):
12 12
     "Returns a description of the table, with the DB-API cursor.description interface."
13 13
     cursor.execute("SELECT * FROM %s WHERE ROWNUM < 2" % quote_name(table_name))
14 14
     return cursor.description
15  
-  
  15
+
16 16
 def _name_to_index(cursor, table_name):
17 17
     """
18 18
     Returns a dictionary of {field_name: field_index} for the given table.
@@ -24,7 +24,7 @@ def get_relations(cursor, table_name):
24 24
     """
25 25
     Returns a dictionary of {field_index: (field_index_other_table, other_table)}
26 26
     representing all relationships to the given table. Indexes are 0-based.
27  
-    """    
  27
+    """
28 28
     cursor.execute("""
29 29
 SELECT ta.column_id - 1, tb.table_name, tb.column_id - 1
30 30
 FROM   user_constraints, USER_CONS_COLUMNS ca, USER_CONS_COLUMNS cb,
@@ -83,7 +83,7 @@ def get_indexes(cursor, table_name):
83 83
         # Here, we skip any indexes across multiple fields.
84 84
         indexes[row[0]] = {'primary_key': row[1], 'unique': row[2]}
85 85
     return indexes
86  
-    
  86
+
87 87
 
88 88
 # Maps type codes to Django Field types.
89 89
 DATA_TYPES_REVERSE = {
3  django/db/backends/util.py
@@ -33,9 +33,6 @@ def executemany(self, sql, param_list):
33 33
                 'time': "%.3f" % (stop - start),
34 34
             })
35 35
 
36  
-    def __iter__(self):
37  
-        return self.cursor.__iter__()
38  
-
39 36
     def __getattr__(self, attr):
40 37
         if self.__dict__.has_key(attr):
41 38
             return self.__dict__[attr]

0 notes on commit 9649bfd

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