From 3bb787a2f7de4aebc276545927eef53de042ffaf Mon Sep 17 00:00:00 2001 From: daxiong Date: Thu, 23 Apr 2020 12:57:44 +0000 Subject: [PATCH] fix GetColumns missing ordinal position (#1660) fix GetColumns missing ordinal position Co-authored-by: zhubo <816078@qq.com> Reviewed-on: https://gitea.com/xorm/xorm/pulls/1660 Reviewed-by: Lunny Xiao --- dialects/mysql.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dialects/mysql.go b/dialects/mysql.go index ac916c89..f9a2e943 100644 --- a/dialects/mysql.go +++ b/dialects/mysql.go @@ -308,7 +308,8 @@ func (db *mysql) AddColumnSQL(tableName string, col *schemas.Column) string { func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName string) ([]string, map[string]*schemas.Column, error) { args := []interface{}{db.uri.DBName, tableName} s := "SELECT `COLUMN_NAME`, `IS_NULLABLE`, `COLUMN_DEFAULT`, `COLUMN_TYPE`," + - " `COLUMN_KEY`, `EXTRA`,`COLUMN_COMMENT` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?" + " `COLUMN_KEY`, `EXTRA`,`COLUMN_COMMENT` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?" + + " ORDER BY `INFORMATION_SCHEMA`.`COLUMNS`.ORDINAL_POSITION" rows, err := queryer.QueryContext(ctx, s, args...) if err != nil {