Skip to content

Commit

Permalink
fix: update omit (#5699)
Browse files Browse the repository at this point in the history
  • Loading branch information
qqxhb committed Sep 16, 2022
1 parent edb00c1 commit 4906259
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions callbacks/update.go
Expand Up @@ -70,10 +70,12 @@ func Update(config *Config) func(db *gorm.DB) {
if db.Statement.SQL.Len() == 0 {
db.Statement.SQL.Grow(180)
db.Statement.AddClauseIfNotExists(clause.Update{})
if set := ConvertToAssignments(db.Statement); len(set) != 0 {
db.Statement.AddClause(set)
} else if _, ok := db.Statement.Clauses["SET"]; !ok {
return
if _, ok := db.Statement.Clauses["SET"]; !ok {
if set := ConvertToAssignments(db.Statement); len(set) != 0 {
db.Statement.AddClause(set)
} else {
return
}
}

db.Statement.Build(db.Statement.BuildClauses...)
Expand Down

1 comment on commit 4906259

@a631807682
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to this issue #5831, although I don't think this change creates a bug, I'd still like to know what it fixes.

Please sign in to comment.