Support specify count select argument

This commit is contained in:
Jinzhu 2016-08-14 15:15:09 +08:00
parent 8f0f5df8c6
commit 34e75afb42
1 changed files with 3 additions and 1 deletions

View File

@ -917,7 +917,9 @@ func (scope *Scope) pluck(column string, value interface{}) *Scope {
} }
func (scope *Scope) count(value interface{}) *Scope { func (scope *Scope) count(value interface{}) *Scope {
scope.Search.Select("count(*)") if query, ok := scope.Search.selects["query"]; !ok || !strings.Contains(fmt.Sprint(query), "count(") {
scope.Search.Select("count(*)")
}
scope.Search.countingQuery = true scope.Search.countingQuery = true
scope.Err(scope.row().Scan(value)) scope.Err(scope.row().Scan(value))
return scope return scope