Remove offset and limit from count queries. Fixes #2443

This commit is contained in:
Deluan 2024-01-20 22:02:05 -05:00 committed by Joe Stump
parent 020f9db5bd
commit 7d33f15eaa
No known key found for this signature in database
GPG Key ID: 29151C3EC48A0EB9
2 changed files with 2 additions and 1 deletions

View File

@ -35,7 +35,7 @@ func (r *radioRepository) isPermitted() bool {
}
func (r *radioRepository) CountAll(options ...model.QueryOptions) (int64, error) {
sql := r.newSelect(options...)
sql := r.newSelect()
return r.count(sql, options...)
}

View File

@ -231,6 +231,7 @@ func (r sqlRepository) exists(existsQuery SelectBuilder) (bool, error) {
func (r sqlRepository) count(countQuery SelectBuilder, options ...model.QueryOptions) (int64, error) {
countQuery = countQuery.
RemoveColumns().Columns("count(distinct " + r.tableName + ".id) as count").
RemoveOffset().RemoveLimit().
From(r.tableName)
countQuery = r.applyFilters(countQuery, options...)
var res struct{ Count int64 }