From 8cd0653baee77528baeba479db6926bf98e8eed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B5=9F?= Date: Thu, 13 Jan 2022 03:50:48 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'create.go'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create.go b/create.go index ae1db85..aae3c3a 100644 --- a/create.go +++ b/create.go @@ -18,7 +18,7 @@ type Column struct { // Create @Title 创建model func Create(db *gorm.DB, table string, path ...string) error { var columns []Column - sql := fmt.Sprintf("select * from information_schema.COLUMNS where table_name ='%s'", db.NamingStrategy.TableName(table)) + sql := fmt.Sprintf("select * from information_schema.COLUMNS where table_name ='%s' order by ordinal_position", db.NamingStrategy.TableName(table)) db.Raw(sql).Scan(&columns) tableName := camelString(table)