From 37eec6e687588d185df7d51aa6e9b1e2669b29b3 Mon Sep 17 00:00:00 2001 From: Subhadip Jana Date: Sat, 20 Jan 2018 09:17:57 +0000 Subject: [PATCH] query: Fix artist and album search return all songs Searching for artist/album returned all songs. Changed sparql where_clause to return songs only specific to the album/artist/composer searched. Fixes https://gitlab.gnome.org/GNOME/gnome-music/issues/4 --- gnomemusic/query.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gnomemusic/query.py b/gnomemusic/query.py index c4ff40c09..3ad1bf6a8 100644 --- a/gnomemusic/query.py +++ b/gnomemusic/query.py @@ -936,26 +936,21 @@ class Query(): @staticmethod def get_songs_with_artist_match(name): name = Tracker.sparql_escape_string(name) - query = """?performer fts:match '"nmm:artistName" : %(name)s*' . """.replace('\n', ' ').strip() % {'name': name} + query = """?song nmm:performer [ fts:match '%(name)s*' ] . """.replace('\n',' ').strip() % {'name': name} return Query.songs(query) @staticmethod def get_songs_with_album_match(name): name = Tracker.sparql_escape_string(name) - query = """?album fts:match '"nie:title" : %(name)s*' . """.replace('\n', ' ').strip() % {'name': name} + query = """?song nmm:musicAlbum [ fts:match '%(name)s*' ] . """.replace('\n', ' ').strip() % {'name': name} return Query.songs(query) @staticmethod def get_songs_with_composer_match(name): name = Tracker.sparql_escape_string(name) - query = """ - ?song nmm:composer ?composer . - ?composer fts:match '"nmm:artistName" : %(name)s*' . - """.replace('\n', ' ').strip() % { - 'name': name - } + query = """?song nmm:composer [ fts:match '%(name)s*' ] . """.replace('\n', ' ').strip() % {'name': name} return Query.songs(query) -- GitLab