Skip to content

Commit f87876d

Browse files
author
ffffwh
committed
api: ListColumns: fix order #1051
and avoid string concat.
1 parent 223904b commit f87876d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

driver/mysql/sql/sqlutils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ func ShowTables(db *gosql.DB, dbName string, showType bool) (tables []*common.Ta
371371

372372
func ListColumns(db *gosql.DB, dbName, tableName string) (columns []string, err error) {
373373
// Get table columns name
374-
query := fmt.Sprintf("select COLUMN_NAME from information_schema.columns where table_name='%s' and table_schema = '%s';", tableName, dbName)
375-
rows, err := db.Query(query)
374+
query := "select COLUMN_NAME from information_schema.columns where table_schema=? and table_name=? order by ORDINAL_POSITION"
375+
rows, err := db.Query(query, dbName, tableName)
376376
if err != nil {
377377
return columns, err
378378
}

0 commit comments

Comments
 (0)