Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix bug in get_indexes affecting the tests

  • Loading branch information...
commit c5e2ecae6949d4e89530610d768bbbd563ddc19b 1 parent d0b3536
Andrew Godwin authored
1  django/db/backends/mysql/introspection.py
@@ -103,6 +103,7 @@ def get_indexes(self, cursor, table_name):
103 103
                 continue
104 104
             if row[4] not in indexes:
105 105
                 indexes[row[4]] = {'primary_key': False, 'unique': False}
  106
+            # It's possible to have the unique and PK constraints in separate indexes.
106 107
             if row[2] == 'PRIMARY':
107 108
                 indexes[row[4]]['primary_key'] = True
108 109
             if not bool(row[1]):
8  django/db/backends/postgresql_psycopg2/introspection.py
@@ -86,7 +86,13 @@ def get_indexes(self, cursor, table_name):
86 86
             # Here, we skip any indexes across multiple fields.
87 87
             if ' ' in row[1]:
88 88
                 continue
89  
-            indexes[row[0]] = {'primary_key': row[3], 'unique': row[2]}
  89
+            if row[0] not in indexes:
  90
+                indexes[row[0]] = {'primary_key': False, 'unique': False}
  91
+            # It's possible to have the unique and PK constraints in separate indexes.
  92
+            if row[3]:
  93
+                indexes[row[0]]['primary_key'] = True
  94
+            if row[2]:
  95
+                indexes[row[0]]['unique'] = True
90 96
         return indexes
91 97
 
92 98
     def get_constraints(self, cursor, table_name):

0 notes on commit c5e2eca

Please sign in to comment.
Something went wrong with that request. Please try again.