From 7d16055a5d33f44df201c310764fedeb0bd6cde4 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 23 Mar 2015 11:07:39 +0800 Subject: [PATCH] Don't use instance setting for order_by_primary_key --- callback_query.go | 2 +- main.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/callback_query.go b/callback_query.go index 4538b272..5daa5fec 100644 --- a/callback_query.go +++ b/callback_query.go @@ -21,7 +21,7 @@ func Query(scope *Scope) { dest = reflect.Indirect(reflect.ValueOf(value)) } - if orderBy, ok := scope.InstanceGet("gorm:order_by_primary_key"); ok { + if orderBy, ok := scope.Get("gorm:order_by_primary_key"); ok { if primaryKey := scope.PrimaryKey(); primaryKey != "" { scope.Search.Order(fmt.Sprintf("%v.%v %v", scope.QuotedTableName(), primaryKey, orderBy)) } diff --git a/main.go b/main.go index b66ceda3..e197a99c 100644 --- a/main.go +++ b/main.go @@ -193,14 +193,14 @@ func (s *DB) Assign(attrs ...interface{}) *DB { func (s *DB) First(out interface{}, where ...interface{}) *DB { newScope := s.clone().NewScope(out) newScope.Search.Limit(1) - return newScope.InstanceSet("gorm:order_by_primary_key", "ASC"). + return newScope.Set("gorm:order_by_primary_key", "ASC"). inlineCondition(where...).callCallbacks(s.parent.callback.queries).db } func (s *DB) Last(out interface{}, where ...interface{}) *DB { newScope := s.clone().NewScope(out) newScope.Search.Limit(1) - return newScope.InstanceSet("gorm:order_by_primary_key", "DESC"). + return newScope.Set("gorm:order_by_primary_key", "DESC"). inlineCondition(where...).callCallbacks(s.parent.callback.queries).db }