Compare commits

..

2 Commits

Author SHA1 Message Date
杨赟 8cd0653bae 更新 'create.go'
3 years ago
kanade ecfa69fddb primaryKey 大写
4 years ago

@ -18,7 +18,7 @@ type Column struct {
// Create @Title 创建model // Create @Title 创建model
func Create(db *gorm.DB, table string, path ...string) error { func Create(db *gorm.DB, table string, path ...string) error {
var columns []Column 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) db.Raw(sql).Scan(&columns)
tableName := camelString(table) tableName := camelString(table)
@ -45,7 +45,7 @@ func Create(db *gorm.DB, table string, path ...string) error {
} }
pri := "" pri := ""
if column.ColumnKey == "PRI" { if column.ColumnKey == "PRI" {
pri = "`gorm:\"primarykey\"`" pri = "`gorm:\"primaryKey\"`"
} }
comment := "" comment := ""
if column.ColumnComment != "" { if column.ColumnComment != "" {

Loading…
Cancel
Save