mirror of https://github.com/go-gorm/gorm.git
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)
|
||||||
|
@ -84,7 +87,6 @@ func Update(db *gorm.DB) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func AfterUpdate(db *gorm.DB) {
|
func AfterUpdate(db *gorm.DB) {
|
||||||
if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && (db.Statement.Schema.AfterSave || db.Statement.Schema.AfterUpdate) {
|
if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && (db.Statement.Schema.AfterSave || db.Statement.Schema.AfterUpdate) {
|
||||||
|
|
Loading…
Reference in New Issue