mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-15 22:07:08 +02:00
fix(pglite): group playlist album ids instead of DISTINCT so random order works
PostgreSQL rejects SELECT DISTINCT with ORDER BY random(), which the playlist cover picker uses to sample album ids. GROUP BY yields the same distinct set and allows the volatile ordering.
This commit is contained in:
parent
e2c8a1930a
commit
9ff44a6854
1 changed files with 4 additions and 2 deletions
|
|
@ -154,9 +154,11 @@ func (r *playlistTrackRepository) GetMediaFileIDs(options ...model.QueryOptions)
|
|||
}
|
||||
|
||||
func (r *playlistTrackRepository) GetAlbumIDs(options ...model.QueryOptions) ([]string, error) {
|
||||
query := r.newSelect(options...).Columns("distinct mf.album_id").
|
||||
// GROUP BY rather than DISTINCT: PostgreSQL rejects DISTINCT with ORDER BY random().
|
||||
query := r.newSelect(options...).Columns("mf.album_id").
|
||||
Join("media_file mf on mf.id = media_file_id").
|
||||
Where(Eq{"playlist_id": r.playlistId})
|
||||
Where(Eq{"playlist_id": r.playlistId}).
|
||||
GroupBy("mf.album_id")
|
||||
var ids []string
|
||||
err := r.queryAllSlice(query, &ids)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue