Skip to content

Commit

Permalink
Fix bug in get_indexes affecting the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgodwin committed Sep 17, 2012
1 parent d0b3536 commit c5e2eca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions django/db/backends/mysql/introspection.py
Expand Up @@ -103,6 +103,7 @@ def get_indexes(self, cursor, table_name):
continue continue
if row[4] not in indexes: if row[4] not in indexes:
indexes[row[4]] = {'primary_key': False, 'unique': False} indexes[row[4]] = {'primary_key': False, 'unique': False}
# It's possible to have the unique and PK constraints in separate indexes.
if row[2] == 'PRIMARY': if row[2] == 'PRIMARY':
indexes[row[4]]['primary_key'] = True indexes[row[4]]['primary_key'] = True
if not bool(row[1]): if not bool(row[1]):
Expand Down
8 changes: 7 additions & 1 deletion django/db/backends/postgresql_psycopg2/introspection.py
Expand Up @@ -86,7 +86,13 @@ def get_indexes(self, cursor, table_name):
# Here, we skip any indexes across multiple fields. # Here, we skip any indexes across multiple fields.
if ' ' in row[1]: if ' ' in row[1]:
continue continue
indexes[row[0]] = {'primary_key': row[3], 'unique': row[2]} if row[0] not in indexes:
indexes[row[0]] = {'primary_key': False, 'unique': False}
# It's possible to have the unique and PK constraints in separate indexes.
if row[3]:
indexes[row[0]]['primary_key'] = True
if row[2]:
indexes[row[0]]['unique'] = True
return indexes return indexes


def get_constraints(self, cursor, table_name): def get_constraints(self, cursor, table_name):
Expand Down

0 comments on commit c5e2eca

Please sign in to comment.