Fix a bug in the column constraint detection

- Without the table constraint any table in the DB that was named the
  same as another would trigger false positives.
This commit is contained in:
Aaron L 2016-07-17 17:47:06 -07:00
parent 71dc36c8e6
commit 423d4b66bf

View file

@ -86,7 +86,7 @@ func (p *PostgresDriver) Columns(tableName string) ([]bdb.Column, error) {
select cast(count(*) as bit) as is_unique
from information_schema.constraint_column_usage as ccu
inner join information_schema.table_constraints tc on ccu.constraint_name = tc.constraint_name
where ccu.column_name = c.column_name and tc.constraint_type = 'UNIQUE'
where ccu.table_name = c.table_name and ccu.column_name = c.column_name and tc.constraint_type = 'UNIQUE'
) as is_unique
from information_schema.columns as c
where table_name=$1 and table_schema = 'public';