From a64523e157a57605c7274f1bcd051ca516b483ae Mon Sep 17 00:00:00 2001 From: lrollus Date: Thu, 9 Dec 2021 13:34:02 +0100 Subject: [PATCH] fix bug with uploaded file + sql request if map is empty --- .../services/be/cytomine/image/UploadedFileService.groovy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grails-app/services/be/cytomine/image/UploadedFileService.groovy b/grails-app/services/be/cytomine/image/UploadedFileService.groovy index c5ba64a05..a165ae888 100644 --- a/grails-app/services/be/cytomine/image/UploadedFileService.groovy +++ b/grails-app/services/be/cytomine/image/UploadedFileService.groovy @@ -125,13 +125,17 @@ class UploadedFileService extends ModelService { "AND uf.content_type NOT similar to '%zip%' " + "AND uf.deleted IS NULL " + "AND " + - search + + (search==null || search.isEmpty() ? "true" : search) + " GROUP BY uf.id, ai.id " + sort def data = [] def sql = new Sql(dataSource) def mapParams = sqlSearchConditions.sqlParameters + println request + if (mapParams instanceof List && mapParams.isEmpty()) { + mapParams = [:] // if sqlSearchConditions.sqlParameters is empty, it return a list, otherwise a map (a bit tricky...). + } mapParams.put("username", user.username) sql.eachRow(request, mapParams) { resultSet -> def row = SQLUtils.keysToCamelCase(resultSet.toRowResult())