Allow customize AutoIncrement for primary field

This commit is contained in:
Jinzhu 2020-07-08 18:50:49 +08:00
parent 30188e7aa4
commit e1084e78d0
1 changed files with 5 additions and 2 deletions

View File

@ -187,8 +187,11 @@ func Parse(dest interface{}, cacheStore *sync.Map, namer Namer) (*Schema, error)
if !field.HasDefaultValue || field.DefaultValueInterface != nil {
schema.FieldsWithDefaultDBValue = append(schema.FieldsWithDefaultDBValue, field)
}
field.HasDefaultValue = true
field.AutoIncrement = true
if _, ok := field.TagSettings["AUTOINCREMENT"]; !ok {
field.HasDefaultValue = true
field.AutoIncrement = true
}
}
}