Skip to content

Commit

Permalink
Merge pull request xbmc#25609 from the-black-eagle/fix_ambiguous_colu…
Browse files Browse the repository at this point in the history
…mn_error

[MUSIC] Fix ambiguous field in SQL if sorting by artist sortname
  • Loading branch information
the-black-eagle authored Aug 20, 2024
2 parents cc6ea42 + 172af71 commit 178dc39
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion xbmc/music/MusicDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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())
Expand Down

0 comments on commit 178dc39

Please sign in to comment.