From 35a2a004d880453f0bbd3716bcc63da1cb15b77b Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 15 Aug 2016 21:28:07 +0800 Subject: [PATCH] Strict select argument check for Count --- scope.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scope.go b/scope.go index e7a53dd4..23a5701b 100644 --- a/scope.go +++ b/scope.go @@ -917,7 +917,7 @@ func (scope *Scope) pluck(column string, 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.countingQuery = true