Skip to content

Commit

Permalink
fix: update omit (go-gorm#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

0 comments on commit 4906259

Please sign in to comment.