From 60b769c2c8ab57eee310d86de11ec6c65b7b21d8 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 4 Jan 2021 15:13:56 +0800 Subject: [PATCH] OnConflict UpdateAll includes fields that specified default values via tag --- callbacks/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callbacks/create.go b/callbacks/create.go index 9166eb67..7bc45a6c 100644 --- a/callbacks/create.go +++ b/callbacks/create.go @@ -337,7 +337,7 @@ func ConvertToCreateValues(stmt *gorm.Statement) (values clause.Values) { columns := make([]string, 0, len(values.Columns)-1) for _, column := range values.Columns { if field := stmt.Schema.LookUpField(column.Name); field != nil { - if !field.PrimaryKey && !field.HasDefaultValue && field.AutoCreateTime == 0 { + if !field.PrimaryKey && (!field.HasDefaultValue || field.DefaultValueInterface != nil) && field.AutoCreateTime == 0 { columns = append(columns, column.Name) } }