Skip to content

🎧 Your Personal Streaming Service

Remove offset and limit from count queries. Fixes #2443

Deluan2b33ef72e36e
diff --git a/persistence/radio_repository.go b/persistence/radio_repository.go
index 93727e4ec..0c0f64d3c 100644
--- a/persistence/radio_repository.go
+++ b/persistence/radio_repository.go
@@ -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...)
}
diff --git a/persistence/sql_base_repository.go b/persistence/sql_base_repository.go
index b3fd7001b..289e15f6f 100644
--- a/persistence/sql_base_repository.go
+++ b/persistence/sql_base_repository.go
@@ -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 }