Django

Code

Changeset 4843

Show
Ignore:
Timestamp:
03/28/07 17:20:22 (2 years ago)
Author:
bouldersprinters
Message:

boulder-oracle-sprint: Fixed #3820. See #3835 too, as this is a more
correct fix for the same issue (CursorDebugWrapper? not iterable).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/boulder-oracle-sprint/django/db/backends/oracle/base.py

    r4776 r4843  
    4646        cursor = FormatStylePlaceholderCursor(self.connection) 
    4747        # default arraysize of 1 is highly sub-optimal 
    48         cursor.arraysize = 256 
     48        cursor.arraysize = 100 
    4949        # set oracle date to ansi date format 
    5050        cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'") 
     
    234234 
    235235    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 
    237237 
    238238    class OracleQuerySet(DefaultQuerySet): 
     
    286286                        yield field 
    287287 
    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 
    297303 
    298304        def _get_sql_clause(self, get_full_query=False): 
  • django/branches/boulder-oracle-sprint/django/db/backends/oracle/introspection.py

    r4279 r4843  
    77    "Returns a list of table names in the current database." 
    88    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()
    1010 
    1111def get_table_description(cursor, table_name): 
     
    1313    cursor.execute("SELECT * FROM %s WHERE ROWNUM < 2" % quote_name(table_name)) 
    1414    return cursor.description 
    15    
     15 
    1616def _name_to_index(cursor, table_name): 
    1717    """ 
     
    2525    Returns a dictionary of {field_index: (field_index_other_table, other_table)} 
    2626    representing all relationships to the given table. Indexes are 0-based. 
    27     """     
     27    """ 
    2828    cursor.execute(""" 
    2929SELECT ta.column_id - 1, tb.table_name, tb.column_id - 1 
     
    8484        indexes[row[0]] = {'primary_key': row[1], 'unique': row[2]} 
    8585    return indexes 
    86      
     86 
    8787 
    8888# Maps type codes to Django Field types. 
  • django/branches/boulder-oracle-sprint/django/db/backends/util.py

    r4840 r4843  
    3333                'time': "%.3f" % (stop - start), 
    3434            }) 
    35  
    36     def __iter__(self): 
    37         return self.cursor.__iter__() 
    3835 
    3936    def __getattr__(self, attr):