From d4f3c109d6d6f2d0f4ae3780f7a74457bfd4a28a Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Tue, 13 Jul 2021 21:29:31 +0800 Subject: [PATCH] Fix OnConflict with one column, close #4370 --- callbacks/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callbacks/create.go b/callbacks/create.go index 2ebe5cab..8a3c593c 100644 --- a/callbacks/create.go +++ b/callbacks/create.go @@ -344,7 +344,7 @@ func ConvertToCreateValues(stmt *gorm.Statement) (values clause.Values) { if c, ok := stmt.Clauses["ON CONFLICT"]; ok { if onConflict, _ := c.Expression.(clause.OnConflict); onConflict.UpdateAll { - if stmt.Schema != nil && len(values.Columns) > 1 { + if stmt.Schema != nil && len(values.Columns) >= 1 { selectColumns, restricted := stmt.SelectAndOmitColumns(true, true) columns := make([]string, 0, len(values.Columns)-1)