diff --git a/lib/prisma.ts b/lib/prisma.ts index 0a10d9816..17638928b 100644 --- a/lib/prisma.ts +++ b/lib/prisma.ts @@ -111,9 +111,16 @@ function getFilterQuery(filters = {}, params = []): string { const filter = filters[key]; if (filter !== undefined) { + let filterValue = decodeURIComponent(filter), + op = '='; const column = FILTER_COLUMNS[key] || key; - arr.push(`and ${column}=$${params.length + 1}`); - params.push(decodeURIComponent(filter)); + + if (filterValue.indexOf('*') > -1) { + op = 'LIKE'; + filterValue = filterValue.replaceAll(/\*+/g, '%'); + } + arr.push(`and ${column} ${op} $${params.length + 1}`); + params.push(filterValue); } return arr;