Fix underspecification of constraint lookups.

This commit is contained in:
Aaron L 2017-01-03 20:29:43 -08:00
parent 5f7bee14a0
commit 14b9122a08

View file

@ -140,7 +140,7 @@ func (m *MySQLDriver) Columns(schema, tableName string) ([]bdb.Column, error) {
on tc.constraint_name = kcu.constraint_name and tc.table_name = kcu.table_name and tc.table_schema = kcu.table_schema
where c.column_name = kcu.column_name and tc.table_name = c.table_name and
(tc.constraint_type = 'PRIMARY KEY' or tc.constraint_type = 'UNIQUE') and
(select count(*) from information_schema.key_column_usage where constraint_name = tc.constraint_name) = 1
(select count(*) from information_schema.key_column_usage where table_schema = kcu.table_schema and table_name = tc.table_name and constraint_name = tc.constraint_name) = 1
) as is_unique
from information_schema.columns as c
where table_name = ? and table_schema = ?;