Merge 238d1d8de84f1fde924afe3f9b6229a22b87af69 into 9acaa33324bbcc78239a1c913d4f1292c12177b9

This commit is contained in:
phproot 2017-05-05 11:31:58 +00:00 committed by GitHub
commit 961e9cfaab

View File

@ -335,7 +335,7 @@ func (scope *Scope) CombinedConditionSql() string {
whereSql = strings.TrimSuffix(strings.TrimPrefix(whereSql, "WHERE ("), ")") whereSql = strings.TrimSuffix(strings.TrimPrefix(whereSql, "WHERE ("), ")")
} }
return joinSql + whereSql + scope.groupSQL() + return joinSql + whereSql + scope.groupSQL() +
scope.havingSQL() + scope.orderSQL() + scope.limitAndOffsetSQL() scope.havingSQL() + scope.orderSQL() + scope.limitAndOffsetSQL() + scope.Search.countEnd
} }
// Raw set raw sql // Raw set raw sql
@ -940,8 +940,13 @@ func (scope *Scope) pluck(column string, value interface{}) *Scope {
func (scope *Scope) count(value interface{}) *Scope { func (scope *Scope) count(value interface{}) *Scope {
if query, ok := scope.Search.selects["query"]; !ok || !countingQueryRegexp.MatchString(fmt.Sprint(query)) { if query, ok := scope.Search.selects["query"]; !ok || !countingQueryRegexp.MatchString(fmt.Sprint(query)) {
if len(scope.Search.group) != 0 {
scope.Search.Select("count(*) FROM ( SELECT count(*) ")
scope.Search.countEnd = " ) AS count"
} else {
scope.Search.Select("count(*)") scope.Search.Select("count(*)")
} }
}
scope.Search.ignoreOrderQuery = true scope.Search.ignoreOrderQuery = true
scope.Err(scope.row().Scan(value)) scope.Err(scope.row().Scan(value))
return scope return scope