From 795328fedc12a34cd2ea7483b2d8ee618bca46c6 Mon Sep 17 00:00:00 2001 From: FWangZil <779158078@qq.com> Date: Mon, 21 Oct 2019 20:45:38 +0800 Subject: [PATCH] fix(HasTable): database name (#2717) * fix(HasTable): database name allow mysql database name with '-' character * docs: add comment --- dialect_mysql.go | 1 + 1 file changed, 1 insertion(+) diff --git a/dialect_mysql.go b/dialect_mysql.go index ee9a43d3..ab6a8a91 100644 --- a/dialect_mysql.go +++ b/dialect_mysql.go @@ -165,6 +165,7 @@ func (s mysql) HasForeignKey(tableName string, foreignKeyName string) bool { func (s mysql) HasTable(tableName string) bool { currentDatabase, tableName := currentDatabaseAndTable(&s, tableName) var name string + // allow mysql database name with '-' character if err := s.db.QueryRow(fmt.Sprintf("SHOW TABLES FROM `%s` WHERE `Tables_in_%s` = ?", currentDatabase, currentDatabase), tableName).Scan(&name); err != nil { if err == sql.ErrNoRows { return false