Skip to content

Commit

Permalink
fix: update omit (#5699)
Browse files Browse the repository at this point in the history
  • Loading branch information
qqxhb authored and jinzhu committed Sep 22, 2022
1 parent 0030c61 commit be32263
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 be32263

Please sign in to comment.