Skip to content

Commit

Permalink
fix: should sort the columns, otherwise the primary key index obtaine…
Browse files Browse the repository at this point in the history
…d is wrong (#131)
  • Loading branch information
dk-lockdown authored Jun 6, 2022
1 parent dbf2287 commit f3bc97f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/meta/table_meta_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ func GetColumns(ctx context.Context, db proto.DB, tableName string) ([]schema.Co
//`EXTRA`, `PRIVILEGES`, `COLUMN_COMMENT`, `GENERATION_EXPRESSION`, `SRS_ID`
s := "SELECT `TABLE_CATALOG`, `TABLE_SCHEMA`, `TABLE_NAME`, `COLUMN_NAME`, `DATA_TYPE`, `CHARACTER_MAXIMUM_LENGTH`, " +
"`NUMERIC_PRECISION`, `NUMERIC_SCALE`, `IS_NULLABLE`, `COLUMN_COMMENT`, `COLUMN_DEFAULT`, `CHARACTER_OCTET_LENGTH`, " +
"`ORDINAL_POSITION`, `COLUMN_KEY`, `EXTRA` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?"
"`ORDINAL_POSITION`, `COLUMN_KEY`, `EXTRA` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? " +
"AND `TABLE_NAME` = ? ORDER BY ORDINAL_POSITION ASC"

// should use new context, otherwise, some filters will be executed repeatedly.
dataTable, _, err := db.ExecuteSql(context.Background(), s, schemaName, tn)
Expand Down

0 comments on commit f3bc97f

Please sign in to comment.