Return genre, artist, album, and album_artist ids in track queries.

This commit is contained in:
Casey Langen 2017-02-02 20:52:13 -08:00
parent 5b9338c61e
commit 85913132e3
2 changed files with 10 additions and 2 deletions

View File

@ -170,7 +170,7 @@ bool LibraryTrack::Load(Track *target, db::Connection &db) {
"ORDER BY tm.id", db);
db::Statement trackQuery(
"SELECT t.track, t.disc, t.bpm, t.duration, t.filesize, t.year, t.title, t.filename, t.thumbnail_id, al.name, t.filetime " \
"SELECT t.track, t.disc, t.bpm, t.duration, t.filesize, t.year, t.title, t.filename, t.thumbnail_id, al.name, t.filetime, t.visual_genre_id, t.visual_artist_id, t.album_artist_id, t.album_id " \
"FROM tracks t, paths p, albums al " \
"WHERE t.id=? AND t.album_id=al.id", db);
@ -187,6 +187,10 @@ bool LibraryTrack::Load(Track *target, db::Connection &db) {
target->SetValue("thumbnail_id", trackQuery.ColumnText(8));
target->SetValue("album", trackQuery.ColumnText(9));
target->SetValue("filetime", trackQuery.ColumnText(10));
target->SetValue("visual_genre_id", trackQuery.ColumnText(11));
target->SetValue("visual_artist_id", trackQuery.ColumnText(12));
target->SetValue("album_artist_id", trackQuery.ColumnText(13));
target->SetValue("album_id", trackQuery.ColumnText(14));
genresQuery.BindInt(0, target->Id());
while (genresQuery.Step() == db::Row) {

View File

@ -220,7 +220,7 @@ TrackMetadataQuery::TrackMetadataQuery(DBID trackId, ILibraryPtr library) {
bool TrackMetadataQuery::OnRun(Connection& db) {
static const std::string query =
"SELECT DISTINCT t.id, t.track, t.disc, t.bpm, t.duration, t.filesize, t.year, t.title, t.filename, t.thumbnail_id, al.name AS album, alar.name AS album_artist, gn.name AS genre, ar.name AS artist, t.filetime "
"SELECT DISTINCT t.id, t.track, t.disc, t.bpm, t.duration, t.filesize, t.year, t.title, t.filename, t.thumbnail_id, al.name AS album, alar.name AS album_artist, gn.name AS genre, ar.name AS artist, t.filetime, t.visual_genre_id, t.visual_artist_id, t.album_artist_id, t.album_id "
"FROM tracks t, paths p, albums al, artists alar, artists ar, genres gn "
"WHERE t.id=? AND t.album_id=al.id AND t.album_artist_id=alar.id AND t.visual_genre_id=gn.id AND t.visual_artist_id=ar.id ";
@ -244,6 +244,10 @@ bool TrackMetadataQuery::OnRun(Connection& db) {
track->SetValue(constants::Track::GENRE, trackQuery.ColumnText(12));
track->SetValue(constants::Track::ARTIST, trackQuery.ColumnText(13));
track->SetValue(constants::Track::FILETIME, trackQuery.ColumnText(14));
track->SetValue(constants::Track::GENRE_ID, trackQuery.ColumnText(15));
track->SetValue(constants::Track::ARTIST_ID, trackQuery.ColumnText(16));
track->SetValue(constants::Track::ALBUM_ARTIST_ID, trackQuery.ColumnText(17));
track->SetValue(constants::Track::ALBUM_ID, trackQuery.ColumnText(18));
this->result = track;
return true;