diff options
Diffstat (limited to 'src/library/dao/playlistdao.cpp')
-rw-r--r-- | src/library/dao/playlistdao.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/library/dao/playlistdao.cpp b/src/library/dao/playlistdao.cpp index 00e22bb4c5..b4226ba9a8 100644 --- a/src/library/dao/playlistdao.cpp +++ b/src/library/dao/playlistdao.cpp @@ -677,13 +677,14 @@ bool PlaylistDAO::copyPlaylistTracks(const int sourcePlaylistID, const int targe // INSERT INTO PlaylistTracks (playlist_id, track_id, position, pl_datetime_added) SELECT :target_plid, track_id, position + :position_offset, pl_datetime_added FROM PlaylistTracks WHERE playlist_id = :source_plid; QSqlQuery query(m_database); query.prepare(QString("INSERT INTO " PLAYLIST_TRACKS_TABLE - " (%1, %2, %3, %4) SELECT :target_plid, %2, " - "%3 + :position_offset, %4 FROM " PLAYLIST_TRACKS_TABLE - " WHERE %1 = :source_plid") - .arg(PLAYLISTTRACKSTABLE_PLAYLISTID) // %1 - .arg(PLAYLISTTRACKSTABLE_TRACKID) // %2 - .arg(PLAYLISTTRACKSTABLE_POSITION) // %3 - .arg(PLAYLISTTRACKSTABLE_DATETIMEADDED)); // %4 + " (%1, %2, %3, %4) SELECT :target_plid, %2, " + "%3 + :position_offset, %4 FROM " PLAYLIST_TRACKS_TABLE + " WHERE %1 = :source_plid") + .arg( + PLAYLISTTRACKSTABLE_PLAYLISTID, // %1 + PLAYLISTTRACKSTABLE_TRACKID, // %2 + PLAYLISTTRACKSTABLE_POSITION, // %3 + PLAYLISTTRACKSTABLE_DATETIMEADDED)); // %4 query.bindValue(":position_offset", positionOffset); query.bindValue(":source_plid", sourcePlaylistID); query.bindValue(":target_plid", targetPlaylistID); @@ -696,10 +697,11 @@ bool PlaylistDAO::copyPlaylistTracks(const int sourcePlaylistID, const int targe // Query each added track and its new position. // SELECT track_id, position FROM PlaylistTracks WHERE playlist_id = :target_plid AND position > :position_offset; query.prepare(QString("SELECT %2, %3 FROM " PLAYLIST_TRACKS_TABLE - " WHERE %1 = :target_plid AND %3 > :position_offset") - .arg(PLAYLISTTRACKSTABLE_PLAYLISTID) // %1 - .arg(PLAYLISTTRACKSTABLE_TRACKID) // %2 - .arg(PLAYLISTTRACKSTABLE_POSITION)); // %3 + " WHERE %1 = :target_plid AND %3 > :position_offset") + .arg( + PLAYLISTTRACKSTABLE_PLAYLISTID, // %1 + PLAYLISTTRACKSTABLE_TRACKID, // %2 + PLAYLISTTRACKSTABLE_POSITION)); // %3 query.bindValue(":target_plid", targetPlaylistID); query.bindValue(":position_offset", positionOffset); if (!query.exec()) { |