style: prepose error judgement

This commit is contained in:
riverchu 2021-09-03 23:09:20 +08:00 committed by Jinzhu
parent a89d4d8fd5
commit 1d9e563023
1 changed files with 26 additions and 24 deletions

View File

@ -51,7 +51,10 @@ func BeforeUpdate(db *gorm.DB) {
}
func Update(db *gorm.DB) {
if db.Error == nil {
if db.Error != nil {
return
}
if db.Statement.Schema != nil && !db.Statement.Unscoped {
for _, c := range db.Statement.Schema.UpdateClauses {
db.Statement.AddClause(c)
@ -83,7 +86,6 @@ func Update(db *gorm.DB) {
db.AddError(err)
}
}
}
}
func AfterUpdate(db *gorm.DB) {