From 8f0f5df8c61312f8859fe866518921fd7bad2046 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sat, 13 Aug 2016 21:46:49 +0800 Subject: [PATCH] Don't set auto increment primary key's HasDefaultValue to true --- model_struct.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model_struct.go b/model_struct.go index d8f9ed1b..d6a71c0b 100644 --- a/model_struct.go +++ b/model_struct.go @@ -175,7 +175,7 @@ func (scope *Scope) GetModelStruct() *ModelStruct { field.HasDefaultValue = true } - if _, ok := field.TagSettings["AUTO_INCREMENT"]; ok { + if _, ok := field.TagSettings["AUTO_INCREMENT"]; ok && !field.IsPrimaryKey { field.HasDefaultValue = true }