Return error happend in Create/Update when using FirstOrCreate

This commit is contained in:
Jinzhu 2015-08-01 12:00:35 +08:00
parent e2e417a8c2
commit a7762ea7d6
1 changed files with 2 additions and 2 deletions

View File

@ -254,9 +254,9 @@ func (s *DB) FirstOrCreate(out interface{}, where ...interface{}) *DB {
if !result.RecordNotFound() { if !result.RecordNotFound() {
return result 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 { } 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 return c
} }