From 3d6d51b5cebfba7630e0e2d88bfd08c3799f96bb Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Tue, 29 Mar 2016 16:46:03 -0500 Subject: [PATCH] DbApi: fix bugs in getPlaylistsWhere. --- .../src/main/groovy/com/jdbernard/wdiwtlt/db/DbApi.groovy | 8 +++++--- 1 file changed, 5 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 ae74c06..abfe523 100644 --- a/core/src/main/groovy/com/jdbernard/wdiwtlt/db/DbApi.groovy +++ b/core/src/main/groovy/com/jdbernard/wdiwtlt/db/DbApi.groovy @@ -167,7 +167,7 @@ public class DbApi { def query = new StringBuilder() .append('DELETE FROM ') .append(pluralize(nameFromModel(model.class.simpleName))) - .append('WHERE id = ?') + .append(' WHERE id = ?') .toString() logger.debug('Deleting model.\n\tSQL: {}\n\tPARAMS: {}', @@ -556,10 +556,12 @@ public class DbApi { if (params.albumId || params.artistId || params.mediaFileId) { query.append(' JOIN playlists_media_files pmf ON ') - .append(' pmf.media_file_id = mf.id ') } + .append(' pmf.playlist_id = p.id ') + .append(' JOIN media_files mf ON ') + .append(' pmf.media_file_id = mf.id ') } if (params.mediaFileId) { - query.append(' AND mf.media_file_id = ? ') + query.append(' AND mf.id = ? ') sqlParams << params.mediaFileId } if (params.albumId) {