Ticket #15933: django_mysql4_multiple_keys_keep_primary.diff

File django_mysql4_multiple_keys_keep_primary.diff, 802 bytes (added by andi, 14 years ago)
  • django/db/backends/mysql/introspection.py

     
    9393        cursor.execute("SHOW INDEX FROM %s" % self.connection.ops.quote_name(table_name))
    9494        indexes = {}
    9595        for row in cursor.fetchall():
    96             indexes[row[4]] = {'primary_key': (row[2] == 'PRIMARY'), 'unique': not bool(row[1])}
     96            if indexes.has_key(row[4]) and indexes[row[4]]['primary_key'] == True:
     97                indexes[row[4]]['unique'] = not bool(row[1])
     98            else:
     99                indexes[row[4]] = {'primary_key': (row[2] == 'PRIMARY'), 'unique': not bool(row[1])}
    97100        return indexes
    98101
Back to Top