Loading django/db/backends/__init__.py +5 −2 Original line number Diff line number Diff line Loading @@ -1034,9 +1034,12 @@ class BaseDatabaseIntrospection(object): def get_primary_key_column(self, cursor, table_name): """ Backends can override this to return the column name of the primary key for the given table. Returns the name of the primary key column for the given table. """ raise NotImplementedError for column in six.iteritems(self.get_indexes(cursor, table_name)): if column[1]['primary_key']: return column[0] return None def get_indexes(self, cursor, table_name): """ Loading django/db/backends/mysql/introspection.py +0 −10 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ import re from .base import FIELD_TYPE from django.db.backends import BaseDatabaseIntrospection from django.utils import six foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)") Loading Loading @@ -88,15 +87,6 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): key_columns.extend(cursor.fetchall()) return key_columns def get_primary_key_column(self, cursor, table_name): """ Returns the name of the primary key column for the given table """ for column in six.iteritems(self.get_indexes(cursor, table_name)): if column[1]['primary_key']: return column[0] return None def get_indexes(self, cursor, table_name): cursor.execute("SHOW INDEX FROM %s" % self.connection.ops.quote_name(table_name)) # Do a two-pass search for indexes: on first pass check which indexes Loading Loading
django/db/backends/__init__.py +5 −2 Original line number Diff line number Diff line Loading @@ -1034,9 +1034,12 @@ class BaseDatabaseIntrospection(object): def get_primary_key_column(self, cursor, table_name): """ Backends can override this to return the column name of the primary key for the given table. Returns the name of the primary key column for the given table. """ raise NotImplementedError for column in six.iteritems(self.get_indexes(cursor, table_name)): if column[1]['primary_key']: return column[0] return None def get_indexes(self, cursor, table_name): """ Loading
django/db/backends/mysql/introspection.py +0 −10 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ import re from .base import FIELD_TYPE from django.db.backends import BaseDatabaseIntrospection from django.utils import six foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)") Loading Loading @@ -88,15 +87,6 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): key_columns.extend(cursor.fetchall()) return key_columns def get_primary_key_column(self, cursor, table_name): """ Returns the name of the primary key column for the given table """ for column in six.iteritems(self.get_indexes(cursor, table_name)): if column[1]['primary_key']: return column[0] return None def get_indexes(self, cursor, table_name): cursor.execute("SHOW INDEX FROM %s" % self.connection.ops.quote_name(table_name)) # Do a two-pass search for indexes: on first pass check which indexes Loading