From a6382da48500a7adfe8a3f75eedc89a34644f54f Mon Sep 17 00:00:00 2001 From: Edgar Fournival Date: Wed, 2 Jan 2019 14:28:02 +0100 Subject: [PATCH] Do not set CreatedAt if blank during Save (#2207) --- callback_update.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callback_update.go b/callback_update.go index f6ba0ffd..c52162c8 100644 --- a/callback_update.go +++ b/callback_update.go @@ -75,7 +75,7 @@ func updateCallback(scope *Scope) { } else { for _, field := range scope.Fields() { if scope.changeableField(field) { - if !field.IsPrimaryKey && field.IsNormal { + if !field.IsPrimaryKey && field.IsNormal && (field.Name != "CreatedAt" || !field.IsBlank) { if !field.IsForeignKey || !field.IsBlank || !field.HasDefaultValue { sqls = append(sqls, fmt.Sprintf("%v = %v", scope.Quote(field.DBName), scope.AddToVars(field.Field.Interface()))) }