From 32f99df53eb75e1c7d4e0af7ace635fc1698d8f1 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Wed, 16 Mar 2016 08:20:44 -0500 Subject: [PATCH] Fixed bugs introduced by trying to use DISCTINCT after ORDER BY. --- core/src/main/groovy/com/jdbernard/wdiwtlt/db/DbApi.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 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 365d6af..230e284 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 DISTINCT * FROM (SELECT mf.* FROM media_files mf ') + query.append('SELECT mf.* FROM media_files mf ') if (params.artistId || params.playlistId) { joins << (newJoin = [ @@ -501,11 +501,11 @@ public class DbApi { if (orderClauses) query.append(' ORDER BY ').append(orderClauses.join(', ')) - query = query.append(') as filtered_sorted_media_files').toString() + query = query.toString() logger.debug('Selecting media files.\n\tSQL: {}\n\tPARAMS: {}', query, sqlParams) return sql.rows(query, sqlParams).collect { - recordToModel(MediaFile, it) } } + recordToModel(MediaFile, it) }.unique() } public List getUntaggedFiles() { String query = """