From 65aa94200b3d10d515b15a78898c3692cd57e6c7 Mon Sep 17 00:00:00 2001 From: zshimanchik Date: Thu, 25 Feb 2016 23:10:03 +0300 Subject: [PATCH] Fixed #24653 -- Fixed MySQL database introspection when using read_default_file. --- django/db/backends/mysql/introspection.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py index 835276d7e1..6b324b738a 100644 --- a/django/db/backends/mysql/introspection.py +++ b/django/db/backends/mysql/introspection.py @@ -165,10 +165,10 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): kc.`referenced_table_name`, kc.`referenced_column_name` FROM information_schema.key_column_usage AS kc WHERE - kc.table_schema = %s AND + kc.table_schema = DATABASE() AND kc.table_name = %s """ - cursor.execute(name_query, [self.connection.settings_dict['NAME'], table_name]) + cursor.execute(name_query, [table_name]) for constraint, column, ref_table, ref_column in cursor.fetchall(): if constraint not in constraints: constraints[constraint] = { @@ -185,10 +185,10 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): SELECT c.constraint_name, c.constraint_type FROM information_schema.table_constraints AS c WHERE - c.table_schema = %s AND + c.table_schema = DATABASE() AND c.table_name = %s """ - cursor.execute(type_query, [self.connection.settings_dict['NAME'], table_name]) + cursor.execute(type_query, [table_name]) for constraint, kind in cursor.fetchall(): if kind.lower() == "primary key": constraints[constraint]['primary_key'] = True