Skip to content

Commit

Permalink
fix GetColumns missing ordinal position
Browse files Browse the repository at this point in the history
  • Loading branch information
xormplus committed Apr 30, 2020
1 parent f6b4c1c commit 2f364d8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dialects/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2f364d8

Please sign in to comment.