forked from mirror/gorm
style: prepose error judgement
This commit is contained in:
parent
a89d4d8fd5
commit
1d9e563023
|
@ -51,7 +51,10 @@ func BeforeUpdate(db *gorm.DB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Update(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 {
|
if db.Statement.Schema != nil && !db.Statement.Unscoped {
|
||||||
for _, c := range db.Statement.Schema.UpdateClauses {
|
for _, c := range db.Statement.Schema.UpdateClauses {
|
||||||
db.Statement.AddClause(c)
|
db.Statement.AddClause(c)
|
||||||
|
@ -83,7 +86,6 @@ func Update(db *gorm.DB) {
|
||||||
db.AddError(err)
|
db.AddError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func AfterUpdate(db *gorm.DB) {
|
func AfterUpdate(db *gorm.DB) {
|
||||||
|
|
Loading…
Reference in New Issue