Fix exception for FirstOrCreate when search condition is nil

This commit is contained in:
Jinzhu 2014-07-01 15:55:19 +08:00
parent 6c5b95e2b2
commit 1c1df2318c
1 changed files with 1 additions and 1 deletions

View File

@ -185,7 +185,7 @@ func (s *DB) FirstOrCreate(out interface{}, where ...interface{}) *DB {
return r return r
} }
c.NewScope(out).inlineCondition(where...).initialize().callCallbacks(s.parent.callback.creates) c.NewScope(out).inlineCondition(where...).initialize().callCallbacks(s.parent.callback.creates)
} else if len(s.search.AssignAttrs) > 0 { } else if len(c.search.AssignAttrs) > 0 {
c.NewScope(out).Set("gorm:update_interface", s.search.AssignAttrs).callCallbacks(s.parent.callback.updates) c.NewScope(out).Set("gorm:update_interface", s.search.AssignAttrs).callCallbacks(s.parent.callback.updates)
} }
return c return c