From 8e145b244d310d2699a6135f7785f551ffe94b8c Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Wed, 16 Mar 2016 05:53:14 -0500 Subject: [PATCH] Fixed a bug where media files associated with multiple artists or albums were returned multiple times. --- core/src/main/groovy/com/jdbernard/wdiwtlt/db/DbApi.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/groovy/com/jdbernard/wdiwtlt/db/DbApi.groovy b/core/src/main/groovy/com/jdbernard/wdiwtlt/db/DbApi.groovy index 02a0126..365d6af 100644 --- a/core/src/main/groovy/com/jdbernard/wdiwtlt/db/DbApi.groovy +++ b/core/src/main/groovy/com/jdbernard/wdiwtlt/db/DbApi.groovy @@ -423,7 +423,7 @@ public class DbApi { def whereClauses = [] def newJoin - query.append('SELECT mf.* FROM media_files mf ') + query.append('SELECT DISTINCT * FROM (SELECT mf.* FROM media_files mf ') if (params.artistId || params.playlistId) { joins << (newJoin = [ @@ -501,7 +501,7 @@ public class DbApi { if (orderClauses) query.append(' ORDER BY ').append(orderClauses.join(', ')) - query = query.toString() + query = query.append(') as filtered_sorted_media_files').toString() logger.debug('Selecting media files.\n\tSQL: {}\n\tPARAMS: {}', query, sqlParams) return sql.rows(query, sqlParams).collect {