Commit b3b5c5f5 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Artist: Add a method to drop artist/media relation

(cherry picked from commit 48e6e92c)
Signed-off-by: default avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent ab585c3b
......@@ -479,6 +479,12 @@ Query<IArtist> Artist::searchByGenre( MediaLibraryPtr ml, const std::string& pat
std::move( groupBy ), pattern, genreId );
}
void Artist::dropMediaArtistRelation( MediaLibraryPtr ml, int64_t mediaId )
{
const std::string req = "DELETE FROM MediaArtistRelation WHERE media_id = ?";
sqlite::Tools::executeDelete( ml->getConn(), req, mediaId );
}
std::string Artist::sortRequest( const QueryParameters* params )
{
std::string req = " ORDER BY name";
......
......@@ -79,6 +79,19 @@ public:
const QueryParameters* params );
static Query<IArtist> searchByGenre( MediaLibraryPtr ml, const std::string& pattern,
const QueryParameters* params, int64_t genreId );
/**
* @brief dropMediaArtistRelation Drops any relation between a media and N artists
* @param ml A media library instance
* @param mediaId The media to drop the relation with
*
* This is intended to remove any link between media & artist(s) when none
* of them is deleted. When any of those 2 entities is deleted, any relation
* will automatically get dropped.
* Effectively, this is meant to be used when refreshing a media, since we
* can't delete it, at the risk of dropping it from any playlist, and we
* won't delete an artist when a media gets updated.
*/
static void dropMediaArtistRelation( MediaLibraryPtr ml, int64_t mediaId );
private:
static std::string sortRequest( const QueryParameters* params );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment