Author: bouldersprinters
Date: 2007-03-28 17:20:22 -0500 (Wed, 28 Mar 2007)
New Revision: 4843

Modified:
   django/branches/boulder-oracle-sprint/django/db/backends/oracle/base.py
   
django/branches/boulder-oracle-sprint/django/db/backends/oracle/introspection.py
   django/branches/boulder-oracle-sprint/django/db/backends/util.py
Log:
boulder-oracle-sprint: Fixed #3820.  See #3835 too, as this is a more 
correct fix for the same issue (CursorDebugWrapper not iterable).


Modified: 
django/branches/boulder-oracle-sprint/django/db/backends/oracle/base.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/db/backends/oracle/base.py     
2007-03-28 21:30:05 UTC (rev 4842)
+++ django/branches/boulder-oracle-sprint/django/db/backends/oracle/base.py     
2007-03-28 22:20:22 UTC (rev 4843)
@@ -45,7 +45,7 @@
                 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 @@
     "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,16 +285,22 @@
                     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, \
                 handle_legacy_orderlist, orderfield2column

Modified: 
django/branches/boulder-oracle-sprint/django/db/backends/oracle/introspection.py
===================================================================
--- 
django/branches/boulder-oracle-sprint/django/db/backends/oracle/introspection.py
    2007-03-28 21:30:05 UTC (rev 4842)
+++ 
django/branches/boulder-oracle-sprint/django/db/backends/oracle/introspection.py
    2007-03-28 22:20:22 UTC (rev 4843)
@@ -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 @@
     """
     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,8 +83,8 @@
         # 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 = {
     16: 'BooleanField',

Modified: django/branches/boulder-oracle-sprint/django/db/backends/util.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/db/backends/util.py    
2007-03-28 21:30:05 UTC (rev 4842)
+++ django/branches/boulder-oracle-sprint/django/db/backends/util.py    
2007-03-28 22:20:22 UTC (rev 4843)
@@ -33,9 +33,6 @@
                 '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]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to