mirror of https://github.com/go-gorm/gorm.git
Support specify count select argument
This commit is contained in:
parent
8f0f5df8c6
commit
34e75afb42
4
scope.go
4
scope.go
|
@ -917,7 +917,9 @@ func (scope *Scope) pluck(column string, 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.Err(scope.row().Scan(value))
|
||||
return scope
|
||||
|
|
Loading…
Reference in New Issue