Enable to decline antuincrement on ID field

This commit is contained in:
otiai10 2015-11-21 18:15:47 +09:00
parent 2f9abdcf02
commit ba12202af2
1 changed files with 4 additions and 1 deletions

View File

@ -435,10 +435,13 @@ func (scope *Scope) generateSqlTag(field *StructField) string {
size, _ = strconv.Atoi(value)
}
_, autoIncrease := sqlSettings["AUTO_INCREMENT"]
v, autoIncrease := sqlSettings["AUTO_INCREMENT"]
if field.IsPrimaryKey {
autoIncrease = true
}
if v == "NO" {
autoIncrease = false
}
sqlType = scope.Dialect().SqlTag(reflectValue, size, autoIncrease)
}