From 073fa4dc85392347f784c61f5db057e7810efe47 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Thu, 17 Sep 2015 21:39:16 +0800 Subject: [PATCH] include order by for group SQL --- scope_private.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scope_private.go b/scope_private.go index f6f815d9..f47c8433 100644 --- a/scope_private.go +++ b/scope_private.go @@ -213,7 +213,7 @@ func (scope *Scope) selectSql() string { return "*" } sql := scope.buildSelectQuery(scope.Search.selects) - scope.Search.countingQuery = hasCountRegexp.MatchString(sql) + scope.Search.countingQuery = (len(scope.Search.group) == 0) && hasCountRegexp.MatchString(sql) return scope.buildSelectQuery(scope.Search.selects) }