From ba12202af2512ba8fc646163483fbefc1d283a20 Mon Sep 17 00:00:00 2001 From: otiai10 Date: Sat, 21 Nov 2015 18:15:47 +0900 Subject: [PATCH 1/2] 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) } From ea83dec21497149dc9ce4dc8d8128f8053e94ceb Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 22 Nov 2015 09:35:18 +0800 Subject: [PATCH 2/2] Use false to decline antuincrement --- model_struct.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model_struct.go b/model_struct.go index 13768a18..4ea821d6 100644 --- a/model_struct.go +++ b/model_struct.go @@ -439,7 +439,7 @@ func (scope *Scope) generateSqlTag(field *StructField) string { if field.IsPrimaryKey { autoIncrease = true } - if v == "NO" { + if v == "FALSE" { autoIncrease = false }