Skip to content

Commit

Permalink
fix mysql table exists check
Browse files Browse the repository at this point in the history
  • Loading branch information
ubaldus committed Apr 1, 2024
1 parent e14eeca commit ac44f68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions db/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,11 @@ func mysqlTableExists(name string) (bool, error) {
return false, err
}

mysqlRun("SET @dbName = DATABASE()")
mysqlRun("CALL sys.table_exists(@dbName,'" + name + "',@tableExists)")
exists, err := mysqlValue("SELECT @tableExists")
count, err := mysqlValue("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = ?", name)
if err != nil {
return false, err
}
return exists != "", nil
return Number(count) > 0, nil
}

// mysqlFieldExists checks if a field with the given name exists in the specified table of the MySQL database.
Expand Down
2 changes: 1 addition & 1 deletion sys/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package sys

const Name = "Tibula"
const Version = "17.3.7"
const Version = "17.4.1"

var Options TypeConfig
var Commands TypeCommand

0 comments on commit ac44f68

Please sign in to comment.