From 5710c6e2db54173b12a5f2789a07c89ae3eda68b Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 18 Feb 2006 21:57:38 +0000 Subject: [PATCH] Changed get_indexes() hook from [2346] to return 'primary_key' instead of 'keyname' git-svn-id: http://code.djangoproject.com/svn/django/trunk@2348 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/db/backends/mysql.py | 4 ++-- django/core/management.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/django/core/db/backends/mysql.py b/django/core/db/backends/mysql.py index c4b2e870ec..d1a3e7ee12 100644 --- a/django/core/db/backends/mysql.py +++ b/django/core/db/backends/mysql.py @@ -139,13 +139,13 @@ def get_indexes(cursor, table_name): """ Returns a dictionary of fieldname -> infodict for the given table, where each infodict is in the format: - {'keyname': 'name of key', + {'primary_key': boolean representing whether it's the primary key, 'unique': boolean representing whether it's a unique index} """ cursor.execute("SHOW INDEX FROM %s" % DatabaseWrapper().quote_name(table_name)) indexes = {} for row in cursor.fetchall(): - indexes[row[4]] = {'keyname': row[2], 'unique': not bool(row[1])} + indexes[row[4]] = {'primary_key': (row[2] == 'PRIMARY'), 'unique': not bool(row[1])} return indexes OPERATOR_MAPPING = { diff --git a/django/core/management.py b/django/core/management.py index 23ee81d0ad..de1153af80 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -636,7 +636,7 @@ def inspectdb(db_name): # Add primary_key and unique, if necessary. column_name = extra_params.get('db_column', att_name) if column_name in indexes: - if indexes[column_name]['keyname'] == 'PRIMARY': + if indexes[column_name]['primary_key']: extra_params['primary_key'] = True elif indexes[column_name]['unique']: extra_params['unique'] = True