mirror of https://github.com/go-gorm/gorm.git
Allow customize AutoIncrement for primary field
This commit is contained in:
parent
30188e7aa4
commit
e1084e78d0
|
@ -187,10 +187,13 @@ func Parse(dest interface{}, cacheStore *sync.Map, namer Namer) (*Schema, error)
|
||||||
if !field.HasDefaultValue || field.DefaultValueInterface != nil {
|
if !field.HasDefaultValue || field.DefaultValueInterface != nil {
|
||||||
schema.FieldsWithDefaultDBValue = append(schema.FieldsWithDefaultDBValue, field)
|
schema.FieldsWithDefaultDBValue = append(schema.FieldsWithDefaultDBValue, field)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := field.TagSettings["AUTOINCREMENT"]; !ok {
|
||||||
field.HasDefaultValue = true
|
field.HasDefaultValue = true
|
||||||
field.AutoIncrement = true
|
field.AutoIncrement = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
callbacks := []string{"BeforeCreate", "AfterCreate", "BeforeUpdate", "AfterUpdate", "BeforeSave", "AfterSave", "BeforeDelete", "AfterDelete", "AfterFind"}
|
callbacks := []string{"BeforeCreate", "AfterCreate", "BeforeUpdate", "AfterUpdate", "BeforeSave", "AfterSave", "BeforeDelete", "AfterDelete", "AfterFind"}
|
||||||
for _, name := range callbacks {
|
for _, name := range callbacks {
|
||||||
|
|
Loading…
Reference in New Issue