Fixed #24653 -- Fixed MySQL database introspection when using read_default_file.

This commit is contained in:
zshimanchik 2016-02-25 23:10:03 +03:00 committed by Tim Graham
parent 62ea86448e
commit 65aa94200b
1 changed files with 4 additions and 4 deletions

View File

@ -165,10 +165,10 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
kc.`referenced_table_name`, kc.`referenced_column_name` kc.`referenced_table_name`, kc.`referenced_column_name`
FROM information_schema.key_column_usage AS kc FROM information_schema.key_column_usage AS kc
WHERE WHERE
kc.table_schema = %s AND kc.table_schema = DATABASE() AND
kc.table_name = %s 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(): for constraint, column, ref_table, ref_column in cursor.fetchall():
if constraint not in constraints: if constraint not in constraints:
constraints[constraint] = { constraints[constraint] = {
@ -185,10 +185,10 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
SELECT c.constraint_name, c.constraint_type SELECT c.constraint_name, c.constraint_type
FROM information_schema.table_constraints AS c FROM information_schema.table_constraints AS c
WHERE WHERE
c.table_schema = %s AND c.table_schema = DATABASE() AND
c.table_name = %s 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(): for constraint, kind in cursor.fetchall():
if kind.lower() == "primary key": if kind.lower() == "primary key":
constraints[constraint]['primary_key'] = True constraints[constraint]['primary_key'] = True