We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent af0c087 commit 11546ceCopy full SHA for 11546ce
example/base/user.go
@@ -24,7 +24,7 @@ import (
24
// +gplus:column=true
25
26
type User struct {
27
- ID int64
+ ID int64 `gorm:"primaryKey"`
28
Username string `gorm:"column:username"`
29
Password string
30
Address string
gplus/base_dao.go
@@ -235,7 +235,12 @@ func getPKColumn[T any]() string {
235
tagSetting := schema.ParseTagSetting(field.Tag.Get("gorm"), ";")
236
isPrimaryKey := utils.CheckTruth(tagSetting["PRIMARYKEY"], tagSetting["PRIMARY_KEY"])
237
if isPrimaryKey {
238
- columnName = tagSetting["COLUMN"]
+ name, ok := tagSetting["COLUMN"]
239
+ if !ok {
240
+ namingStrategy := schema.NamingStrategy{}
241
+ name = namingStrategy.ColumnName("", field.Name)
242
+ }
243
+ columnName = name
244
break
245
}
246
0 commit comments