summaryrefslogtreecommitdiff
path: root/django/db/backends/sqlite3/introspection.py
diff options
context:
space:
mode:
authorDerek Anderson <public@kered.org>2007-08-02 21:17:23 +0000
committerDerek Anderson <public@kered.org>2007-08-02 21:17:23 +0000
commitfd77e425091fdeaf321ca7658534c2f906074084 (patch)
treeef89c6900c0b02a91f0cc610a8b65dccc7fcbf92 /django/db/backends/sqlite3/introspection.py
parent38c1cd721dc78b17088257caff78f668315d9b25 (diff)
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 git-svn-id: http://code.djangoproject.com/svn/django/branches/schema-evolution@5787 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends/sqlite3/introspection.py')
-rw-r--r--django/db/backends/sqlite3/introspection.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py
index b59ba70312..8ab8773ddf 100644
--- a/django/db/backends/sqlite3/introspection.py
+++ b/django/db/backends/sqlite3/introspection.py
@@ -26,9 +26,6 @@ def get_indexes(cursor, table_name):
'unique': boolean representing whether it's a unique index}
"""
indexes = {}
- for info in _table_info(cursor, table_name):
- indexes[info['name']] = {'primary_key': info['pk'] != 0,
- 'unique': False}
cursor.execute('PRAGMA index_list(%s)' % quote_name(table_name))
# seq, name, unique
for index, unique in [(field[1], field[2]) for field in cursor.fetchall()]:
@@ -36,11 +33,16 @@ def get_indexes(cursor, table_name):
continue
cursor.execute('PRAGMA index_info(%s)' % quote_name(index))
info = cursor.fetchall()
- # Skip indexes across multiple fields
- if len(info) != 1:
- continue
- name = info[0][2] # seqno, cid, name
- indexes[name]['unique'] = True
+ for x in info:
+ name = x[2] # seqno, cid, name
+ cursor.execute('PRAGMA table_info(%s)' % quote_name(table_name))
+ for row in cursor.fetchall():
+ if row[1]==name:
+ indexes[name] = {'primary_key': False, 'unique': False}
+ if row[2]=='integer':
+ indexes[name]['primary_key'] = True
+ else:
+ indexes[name]['unique'] = True
return indexes
def get_columns(cursor, table_name):