From cf73d5a26d10b4faa46265f622a50db3a2e7e811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alban=20F=C3=A9ron?= Date: Sat, 18 Mar 2023 17:39:07 +0100 Subject: [PATCH] Fix getAlbumList2 for PostgreSQL Closes #245 (for real) --- supysonic/api/albums_songs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/supysonic/api/albums_songs.py b/supysonic/api/albums_songs.py index 148a124..e288098 100644 --- a/supysonic/api/albums_songs.py +++ b/supysonic/api/albums_songs.py @@ -142,7 +142,7 @@ def album_list_id3(): offset = int(offset) if offset else 0 root = get_root_folder(mfid) - query = Album.select().join(Track).group_by(Album) + query = Album.select().join(Track).group_by(Album.id) if root is not None: query = query.where(Track.root_folder == root) @@ -171,7 +171,12 @@ def album_list_id3(): elif ltype == "alphabeticalByName": query = query.order_by(Album.name) elif ltype == "alphabeticalByArtist": - query = query.switch().join(Artist).order_by(Artist.name, Album.name) + query = ( + query.switch() + .join(Artist) + .group_by_extend(Artist.id) + .order_by(Artist.name, Album.name) + ) elif ltype == "byYear": startyear = int(request.values["fromYear"]) endyear = int(request.values["toYear"])