Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed get_indexes() hook from [2346] to return 'primary_key' instea…

…d of 'keyname'

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2348 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5710c6e2db54173b12a5f2789a07c89ae3eda68b 1 parent 27b41fd
Adrian Holovaty authored February 18, 2006
4  django/core/db/backends/mysql.py
@@ -139,13 +139,13 @@ def get_indexes(cursor, table_name):
139 139
     """
140 140
     Returns a dictionary of fieldname -> infodict for the given table,
141 141
     where each infodict is in the format:
142  
-        {'keyname': 'name of key',
  142
+        {'primary_key': boolean representing whether it's the primary key,
143 143
          'unique': boolean representing whether it's a unique index}
144 144
     """
145 145
     cursor.execute("SHOW INDEX FROM %s" % DatabaseWrapper().quote_name(table_name))
146 146
     indexes = {}
147 147
     for row in cursor.fetchall():
148  
-        indexes[row[4]] = {'keyname': row[2], 'unique': not bool(row[1])}
  148
+        indexes[row[4]] = {'primary_key': (row[2] == 'PRIMARY'), 'unique': not bool(row[1])}
149 149
     return indexes
150 150
 
151 151
 OPERATOR_MAPPING = {
2  django/core/management.py
@@ -636,7 +636,7 @@ def table2model(table_name):
636 636
                 # Add primary_key and unique, if necessary.
637 637
                 column_name = extra_params.get('db_column', att_name)
638 638
                 if column_name in indexes:
639  
-                    if indexes[column_name]['keyname'] == 'PRIMARY':
  639
+                    if indexes[column_name]['primary_key']:
640 640
                         extra_params['primary_key'] = True
641 641
                     elif indexes[column_name]['unique']:
642 642
                         extra_params['unique'] = True

0 notes on commit 5710c6e

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