Strict select argument check for Count

This commit is contained in:
Jinzhu 2016-08-15 21:28:07 +08:00
parent 2f27f0f27f
commit 35a2a004d8
1 changed files with 1 additions and 1 deletions

View File

@ -917,7 +917,7 @@ 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 || !strings.Contains(fmt.Sprint(query), "count(") { if query, ok := scope.Search.selects["query"]; !ok || !regexp.MustCompile("(?i)^count(.+)$").MatchString(fmt.Sprint(query)) {
scope.Search.Select("count(*)") scope.Search.Select("count(*)")
} }
scope.Search.countingQuery = true scope.Search.countingQuery = true