Skip to content

Commit

Permalink
Do not set CreatedAt if blank during Save (go-gorm#2207)
Browse files Browse the repository at this point in the history
  • Loading branch information
efournival authored and jinzhu committed Jan 2, 2019
1 parent e2cfd6b commit a6382da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion callback_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())))
}
Expand Down

0 comments on commit a6382da

Please sign in to comment.