diff --git a/persistence/album_repository.go b/persistence/album_repository.go index 8f0fffc4a..ca05bd283 100644 --- a/persistence/album_repository.go +++ b/persistence/album_repository.go @@ -76,7 +76,6 @@ func artistFilter(field string, value interface{}) Sqlizer { func (r *albumRepository) CountAll(options ...model.QueryOptions) (int64, error) { sql := r.newSelectWithAnnotation("album.id") - sql = r.withGenres(sql) return r.count(sql, options...) } diff --git a/persistence/artist_repository.go b/persistence/artist_repository.go index e4a0a0f76..6097ae576 100644 --- a/persistence/artist_repository.go +++ b/persistence/artist_repository.go @@ -52,7 +52,6 @@ func (r *artistRepository) selectArtist(options ...model.QueryOptions) SelectBui func (r *artistRepository) CountAll(options ...model.QueryOptions) (int64, error) { sql := r.newSelectWithAnnotation("artist.id") - sql = r.withGenres(sql) return r.count(sql, options...) } diff --git a/persistence/mediafile_repository.go b/persistence/mediafile_repository.go index d242a2813..783beb7f7 100644 --- a/persistence/mediafile_repository.go +++ b/persistence/mediafile_repository.go @@ -40,7 +40,6 @@ func NewMediaFileRepository(ctx context.Context, o orm.QueryExecutor) *mediaFile func (r *mediaFileRepository) CountAll(options ...model.QueryOptions) (int64, error) { sql := r.newSelectWithAnnotation("media_file.id") - sql = r.withGenres(sql) return r.count(sql, options...) } diff --git a/persistence/sql_base_repository.go b/persistence/sql_base_repository.go index 162bc4385..2774089ae 100644 --- a/persistence/sql_base_repository.go +++ b/persistence/sql_base_repository.go @@ -180,7 +180,8 @@ func (r sqlRepository) exists(existsQuery SelectBuilder) (bool, error) { } func (r sqlRepository) count(countQuery SelectBuilder, options ...model.QueryOptions) (int64, error) { - countQuery = countQuery.Columns("count(distinct " + r.tableName + ".id) as count").From(r.tableName) + countQuery = countQuery. + RemoveColumns().Columns("count(*) as count").From(r.tableName) countQuery = r.applyFilters(countQuery, options...) var res struct{ Count int64 } err := r.queryOne(countQuery, &res)