From 4ef030c9ccb6a9b92b48af4777efef37f0391a16 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 9 Mar 2020 06:37:03 +0000 Subject: [PATCH] =?UTF-8?q?mysql8.0=20=E4=B8=AD=E5=90=8C=E6=AD=A5=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=89=8D=EF=BC=8C=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=BB=93=E6=9E=84=EF=BC=8C=E5=9B=A0tableRaw=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E5=AF=BC=E8=87=B4=E5=90=8C=E6=AD=A5=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=20(#808)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mysql8.0 中同步数据前,获取数据库结构,因tableRaw为空导致同步失败 Co-authored-by: 崔彦鹏 Reviewed-on: https://gitea.com/xorm/xorm/pulls/808 --- dialects/mysql.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dialects/mysql.go b/dialects/mysql.go index 78acf1d0..b7598680 100644 --- a/dialects/mysql.go +++ b/dialects/mysql.go @@ -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) { 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')" 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) for rows.Next() { table := schemas.NewEmptyTable() - var name, engine, tableRows, comment string - var autoIncr *string - err = rows.Scan(&name, &engine, &tableRows, &autoIncr, &comment) + var name, engine string + var autoIncr, comment *string + err = rows.Scan(&name, &engine, &autoIncr, &comment) if err != nil { return nil, err } table.Name = name - table.Comment = comment + if comment != nil { + table.Comment = *comment + } table.StoreEngine = engine tables = append(tables, table) }