forked from mirror/gorm
Support specify count select argument
This commit is contained in:
parent
8f0f5df8c6
commit
34e75afb42
2
scope.go
2
scope.go
|
@ -917,7 +917,9 @@ 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(") {
|
||||
scope.Search.Select("count(*)")
|
||||
}
|
||||
scope.Search.countingQuery = true
|
||||
scope.Err(scope.row().Scan(value))
|
||||
return scope
|
||||
|
|
Loading…
Reference in New Issue