mirror of https://github.com/go-gorm/gorm.git
Return error happend in Create/Update when using FirstOrCreate
This commit is contained in:
parent
e2e417a8c2
commit
a7762ea7d6
4
main.go
4
main.go
|
@ -254,9 +254,9 @@ func (s *DB) FirstOrCreate(out interface{}, where ...interface{}) *DB {
|
|||
if !result.RecordNotFound() {
|
||||
return result
|
||||
}
|
||||
c.NewScope(out).inlineCondition(where...).initialize().callCallbacks(s.parent.callback.creates)
|
||||
c.err(c.NewScope(out).inlineCondition(where...).initialize().callCallbacks(s.parent.callback.creates).db.Error)
|
||||
} else if len(c.search.assignAttrs) > 0 {
|
||||
c.NewScope(out).InstanceSet("gorm:update_interface", s.search.assignAttrs).callCallbacks(s.parent.callback.updates)
|
||||
c.err(c.NewScope(out).InstanceSet("gorm:update_interface", s.search.assignAttrs).callCallbacks(s.parent.callback.updates).db.Error)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue