From a7762ea7d6a6d2c24c6b3541cb16347e15f69bcc Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sat, 1 Aug 2015 12:00:35 +0800 Subject: [PATCH] Return error happend in Create/Update when using FirstOrCreate --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4e93ba28..dbac3b33 100644 --- a/main.go +++ b/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 }