fix: update omit (#5699)

This commit is contained in:
qqxhb 2022-09-16 15:02:44 +08:00 committed by GitHub
parent edb00c10ad
commit 490625981a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -70,10 +70,12 @@ func Update(config *Config) func(db *gorm.DB) {
if db.Statement.SQL.Len() == 0 { if db.Statement.SQL.Len() == 0 {
db.Statement.SQL.Grow(180) db.Statement.SQL.Grow(180)
db.Statement.AddClauseIfNotExists(clause.Update{}) db.Statement.AddClauseIfNotExists(clause.Update{})
if set := ConvertToAssignments(db.Statement); len(set) != 0 { if _, ok := db.Statement.Clauses["SET"]; !ok {
db.Statement.AddClause(set) if set := ConvertToAssignments(db.Statement); len(set) != 0 {
} else if _, ok := db.Statement.Clauses["SET"]; !ok { db.Statement.AddClause(set)
return } else {
return
}
} }
db.Statement.Build(db.Statement.BuildClauses...) db.Statement.Build(db.Statement.BuildClauses...)