Find: order by primary key by default

This commit is contained in:
Luc Scieux 2016-08-11 18:00:34 +02:00
parent dda88dd08c
commit 7afe504a13

View File

@ -253,7 +253,8 @@ func (s *DB) Last(out interface{}, where ...interface{}) *DB {
// Find find records that match given conditions // Find find records that match given conditions
func (s *DB) Find(out interface{}, where ...interface{}) *DB { func (s *DB) Find(out interface{}, where ...interface{}) *DB {
return s.clone().NewScope(out).inlineCondition(where...).callCallbacks(s.parent.callbacks.queries).db newScope := s.clone().NewScope(out)
return newScope.Set("gorm:order_by_primary_key", "ASC").inlineCondition(where...).callCallbacks(s.parent.callbacks.queries).db
} }
// Scan scan value to a struct // Scan scan value to a struct