Django

Code

Show
Ignore:
Timestamp:
08/02/07 16:17:23 (1 year ago)
Author:
danderson
Message:

schema-evolution:
added sqlite3 unit tests
greatly expanded the number of evolutions supported by the sqlite3 backend
changed all get_<evolution_type> calls to return lists of strings
fixed sqlite3 get_indexes introspection

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/schema-evolution/django/db/backends/sqlite3/introspection.py

    r5785 r5787  
    2727    """ 
    2828    indexes = {} 
    29     for info in _table_info(cursor, table_name): 
    30         indexes[info['name']] = {'primary_key': info['pk'] != 0, 
    31                                  'unique': False} 
    3229    cursor.execute('PRAGMA index_list(%s)' % quote_name(table_name)) 
    3330    # seq, name, unique 
     
    3734        cursor.execute('PRAGMA index_info(%s)' % quote_name(index)) 
    3835        info = cursor.fetchall() 
    39         # Skip indexes across multiple fields 
    40         if len(info) != 1: 
    41             continue 
    42         name = info[0][2] # seqno, cid, name 
    43         indexes[name]['unique'] = True 
     36        for x in info: 
     37            name = x[2] # seqno, cid, name 
     38            cursor.execute('PRAGMA table_info(%s)' % quote_name(table_name)) 
     39            for row in cursor.fetchall(): 
     40                if row[1]==name: 
     41                    indexes[name] = {'primary_key': False, 'unique': False} 
     42                    if row[2]=='integer': 
     43                        indexes[name]['primary_key'] = True 
     44                    else: 
     45                        indexes[name]['unique'] = True 
    4446    return indexes 
    4547