fix count() bug
This commit is contained in:
parent
2bd6928400
commit
238d1d8de8
4
scope.go
4
scope.go
@ -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
|
||||||
@ -942,7 +942,7 @@ 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 {
|
if len(scope.Search.group) != 0 {
|
||||||
scope.Search.Select("count(*) FROM ( SELECT count(*) ")
|
scope.Search.Select("count(*) FROM ( SELECT count(*) ")
|
||||||
scope.Search.group += " ) AS count"
|
scope.Search.countEnd = " ) AS count"
|
||||||
} else {
|
} else {
|
||||||
scope.Search.Select("count(*)")
|
scope.Search.Select("count(*)")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user