Don't include Order for counting sql
This commit is contained in:
parent
6b8f2fcab8
commit
d21eed4b66
@ -206,15 +206,19 @@ func (scope *Scope) whereSql() (sql string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasCountRegexp = regexp.MustCompile(`(?i)count(.+)`)
|
||||||
|
|
||||||
func (scope *Scope) selectSql() string {
|
func (scope *Scope) selectSql() string {
|
||||||
if len(scope.Search.selects) == 0 {
|
if len(scope.Search.selects) == 0 {
|
||||||
return "*"
|
return "*"
|
||||||
}
|
}
|
||||||
|
sql := scope.buildSelectQuery(scope.Search.selects)
|
||||||
|
scope.Search.countingQuery = hasCountRegexp.MatchString(sql)
|
||||||
return scope.buildSelectQuery(scope.Search.selects)
|
return scope.buildSelectQuery(scope.Search.selects)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scope *Scope) orderSql() string {
|
func (scope *Scope) orderSql() string {
|
||||||
if len(scope.Search.orders) == 0 {
|
if len(scope.Search.orders) == 0 || scope.Search.countingQuery {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return " ORDER BY " + strings.Join(scope.Search.orders, ",")
|
return " ORDER BY " + strings.Join(scope.Search.orders, ",")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user