@ -8,6 +8,8 @@
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@ -44,12 +46,11 @@ func (sd *SystemDao) GetTableList(dbInstance *gorm.DB) ([]string, error) {
|
||||
func (sd *SystemDao) GetCreateTableSQL(dbInstance *gorm.DB, table string) (string, error) {
|
||||
var (
|
||||
err error
|
||||
result string
|
||||
result map[string]interface{}
|
||||
)
|
||||
|
||||
if err = dbInstance.Raw("SHOW CREATE TABLE " + table).Scan(&result).Error; nil != err {
|
||||
err = dbInstance.Exec("SHOW CREATE TABLE `" + table + "`;").Row().Scan(&result)
|
||||
if err = dbInstance.Raw("SHOW CREATE TABLE `" + table + "`").Scan(&result).Error; nil != err {
|
||||
return "", err
|
||||
}
|
||||
return result, nil
|
||||
return fmt.Sprintf("%v", result["Create Table"]), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user