diff --git a/core/src/main/groovy/com/jdbernard/wdiwtlt/db/ORM.groovy b/core/src/main/groovy/com/jdbernard/wdiwtlt/db/ORM.groovy index 6ceefa2..a503262 100644 --- a/core/src/main/groovy/com/jdbernard/wdiwtlt/db/ORM.groovy +++ b/core/src/main/groovy/com/jdbernard/wdiwtlt/db/ORM.groovy @@ -738,7 +738,7 @@ public class ORM { def query = new StringBuilder() def sqlParams = [] - query.append('SELECT DISTINCT t.* FROM tags ') + query.append('SELECT DISTINCT t.* FROM tags t ') if (params.mediaFileId || params.artistId || params.albumId || params.playlistId) @@ -768,7 +768,12 @@ public class ORM { if (params.name) { query.append(' WHERE t.name = ? ') - sqlParams << params.name } } + sqlParams << params.name } + + query = query.toString() + logger.debug('Selecting tags.\n\tSQL: {}\n\tPARAMS: {}', + query, sqlParams) + return sql.rows(query, sqlParams).collect { recordToModel(Tag, it) } } public def tagMediaFiles(List mediaFileIds, List tagNames) { String insertQuery = 'INSERT INTO media_files_tags VALUES (?, ?)'