From ba12202af2512ba8fc646163483fbefc1d283a20 Mon Sep 17 00:00:00 2001 From: otiai10 Date: Sat, 21 Nov 2015 18:15:47 +0900 Subject: [PATCH] Enable to decline antuincrement on ID field --- model_struct.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/model_struct.go b/model_struct.go index bd766b85..13768a18 100644 --- a/model_struct.go +++ b/model_struct.go @@ -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) }