mirror of https://github.com/go-gorm/gorm.git
Fix FieldsWithDefaultDBValue for primary field, close #3187
This commit is contained in:
parent
87112ab1c7
commit
7021db3655
|
@ -184,11 +184,11 @@ func Parse(dest interface{}, cacheStore *sync.Map, namer Namer) (*Schema, error)
|
||||||
if field := schema.PrioritizedPrimaryField; field != nil {
|
if field := schema.PrioritizedPrimaryField; field != nil {
|
||||||
switch field.GORMDataType {
|
switch field.GORMDataType {
|
||||||
case Int, Uint:
|
case Int, Uint:
|
||||||
|
if _, ok := field.TagSettings["AUTOINCREMENT"]; !ok {
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue