#1412·xorm

sync2 不支持同步 MySQL 中的 MEMORY 引擎数据表 V0.7.0

作者: ependi-buzz创建于 2019年9月2日更新于 2019年9月30日
标签enhancement

func (db *MySQL) GetTables() ([]*core.Table, error) { args := []interface{}{db.DbName} s := "SELECT TABLE_NAME, ENGINE, TABLE_ROWS, AUTO_INCREMENT, TABLE_COMMENT from " + "INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=? AND (ENGINE='MyISAM' OR ENGINE = 'InnoDB' OR ENGINE = 'TokuDB')" db.LogSQL(s, args) rows, err := db.DB().Query(s, args...) if err != nil { return nil, err } defer rows.Close()

tables := make([]*core.Table, 0)
for rows.Next() {
	table := core.NewEmptyTable()
	var name, engine, tableRows, comment string
	var autoIncr *string
	err = rows.Scan(&name, &engine, &tableRows, &autoIncr, &comment)
	if err != nil {
		return nil, err
	}

	table.Name = name
	table.Comment = comment
	table.StoreEngine = engine
	tables = append(tables, table)
}
return tables, nil

}