mysql8.0 中同步数据前,获取数据库结构,因tableRaw为空导致同步失败 (#808)

mysql8.0 中同步数据前,获取数据库结构,因tableRaw为空导致同步失败

Co-authored-by: 崔彦鹏 <mohong122@qq.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/808
This commit is contained in:
Lunny Xiao 2020-03-09 06:37:03 +00:00
parent 3617ee736f
commit 4ef030c9cc
1 changed files with 7 additions and 5 deletions

View File

@ -413,7 +413,7 @@ func (db *mysql) GetColumns(ctx context.Context, tableName string) ([]string, ma
func (db *mysql) GetTables(ctx context.Context) ([]*schemas.Table, error) { func (db *mysql) GetTables(ctx context.Context) ([]*schemas.Table, error) {
args := []interface{}{db.uri.DBName} args := []interface{}{db.uri.DBName}
s := "SELECT `TABLE_NAME`, `ENGINE`, `TABLE_ROWS`, `AUTO_INCREMENT`, `TABLE_COMMENT` from " + s := "SELECT `TABLE_NAME`, `ENGINE`, `AUTO_INCREMENT`, `TABLE_COMMENT` from " +
"`INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`=? AND (`ENGINE`='MyISAM' OR `ENGINE` = 'InnoDB' OR `ENGINE` = 'TokuDB')" "`INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`=? AND (`ENGINE`='MyISAM' OR `ENGINE` = 'InnoDB' OR `ENGINE` = 'TokuDB')"
rows, err := db.DB().QueryContext(ctx, s, args...) rows, err := db.DB().QueryContext(ctx, s, args...)
@ -425,15 +425,17 @@ func (db *mysql) GetTables(ctx context.Context) ([]*schemas.Table, error) {
tables := make([]*schemas.Table, 0) tables := make([]*schemas.Table, 0)
for rows.Next() { for rows.Next() {
table := schemas.NewEmptyTable() table := schemas.NewEmptyTable()
var name, engine, tableRows, comment string var name, engine string
var autoIncr *string var autoIncr, comment *string
err = rows.Scan(&name, &engine, &tableRows, &autoIncr, &comment) err = rows.Scan(&name, &engine, &autoIncr, &comment)
if err != nil { if err != nil {
return nil, err return nil, err
} }
table.Name = name table.Name = name
table.Comment = comment if comment != nil {
table.Comment = *comment
}
table.StoreEngine = engine table.StoreEngine = engine
tables = append(tables, table) tables = append(tables, table)
} }