From 172af71be18a4891c0817e9be8c3398ed69ebb7a Mon Sep 17 00:00:00 2001 From: the-black-eagle Date: Wed, 14 Aug 2024 08:50:31 +0100 Subject: [PATCH] [MUSIC] Fix ambiguous field in SQL if sorting by artist sortname --- xbmc/music/MusicDatabase.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp index 33896766baf3b..99d5a76ffc735 100644 --- a/xbmc/music/MusicDatabase.cpp +++ b/xbmc/music/MusicDatabase.cpp @@ -13234,6 +13234,13 @@ int CMusicDatabase::GetOrderFilter(const std::string& type, } } + // Get the right tableview as if we are using strArtistSort the column name is ambiguous + std::string table; + if (StringUtils::StartsWithNoCase(type, "album")) + table = "albumview."; + else if (StringUtils::StartsWithNoCase(type, "song")) + table = "songview."; + // Convert field names into order by statement elements for (auto& name : orderfields) { @@ -13242,7 +13249,8 @@ int CMusicDatabase::GetOrderFilter(const std::string& type, if (StringUtils::EndsWith(name, "strArtists") || StringUtils::EndsWith(name, "strArtist")) { if (StringUtils::EndsWith(name, "strArtists")) - sortSQL = SortnameBuildSQL("artistsortname", sorting.sortAttributes, name, "strArtistSort"); + sortSQL = SortnameBuildSQL("artistsortname", sorting.sortAttributes, name, + table + "strArtistSort"); else sortSQL = SortnameBuildSQL("artistsortname", sorting.sortAttributes, name, "strSortName"); if (!sortSQL.empty())