Fix OnConflict with one column, close #4370

This commit is contained in:
Jinzhu 2021-07-13 21:29:31 +08:00
parent 83530ec659
commit d4f3c109d6
1 changed files with 1 additions and 1 deletions

View File

@ -344,7 +344,7 @@ func ConvertToCreateValues(stmt *gorm.Statement) (values clause.Values) {
if c, ok := stmt.Clauses["ON CONFLICT"]; ok { if c, ok := stmt.Clauses["ON CONFLICT"]; ok {
if onConflict, _ := c.Expression.(clause.OnConflict); onConflict.UpdateAll { 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) selectColumns, restricted := stmt.SelectAndOmitColumns(true, true)
columns := make([]string, 0, len(values.Columns)-1) columns := make([]string, 0, len(values.Columns)-1)