From 7afe504a13adabd887e7243859305ddefd318522 Mon Sep 17 00:00:00 2001 From: Luc Scieux Date: Thu, 11 Aug 2016 18:00:34 +0200 Subject: [PATCH] Find: order by primary key by default --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 04f39228..81129b85 100644 --- a/main.go +++ b/main.go @@ -253,7 +253,8 @@ func (s *DB) Last(out interface{}, where ...interface{}) *DB { // Find find records that match given conditions 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