Fix problem with mysql table query.

This commit is contained in:
Aaron L 2016-09-08 23:04:33 -07:00
parent 1e0b90a99c
commit aadcf63e52

View file

@ -80,12 +80,12 @@ func (m *MySQLDriver) TableNames(schema string, whitelist, blacklist []string) (
query := fmt.Sprintf(`select table_name from information_schema.tables where table_schema = ?`)
args := []interface{}{schema}
if len(whitelist) > 0 {
query += fmt.Sprintf("and table_name in (%s);", strings.Repeat(",?", len(whitelist))[1:])
query += fmt.Sprintf(" and table_name in (%s);", strings.Repeat(",?", len(whitelist))[1:])
for _, w := range whitelist {
args = append(args, w)
}
} else if len(blacklist) > 0 {
query += fmt.Sprintf("and table_name not in (%s);", strings.Repeat(",?", len(blacklist))[1:])
query += fmt.Sprintf(" and table_name not in (%s);", strings.Repeat(",?", len(blacklist))[1:])
for _, b := range blacklist {
args = append(args, b)
}