Skip to content

Commit

Permalink
fix case sensitivity for psql getValues
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscao633 committed Apr 10, 2024
1 parent 6973b2b commit 7899289
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/lib/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ function getTimestampDiffQuery(field1: string, field2: string): string {
}
}

function getSearchQuery(column: string): string {
const db = getDatabaseType();
const like = db === POSTGRESQL ? 'ilike' : 'like';

return `and ${column} ${like} {{search}}`;
}

function mapFilter(column: string, operator: string, name: string, type: string = '') {
const db = getDatabaseType();
const like = db === POSTGRESQL ? 'ilike' : 'like';
Expand Down Expand Up @@ -253,6 +260,7 @@ export default {
getFilterQuery,
getSearchParameters,
getTimestampDiffQuery,
getSearchQuery,
getQueryMode,
pagedQuery,
parseFilters,
Expand Down
4 changes: 2 additions & 2 deletions src/queries/analytics/getValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ async function relationalQuery(
endDate: Date,
search: string,
) {
const { rawQuery } = prisma;
const { rawQuery, getSearchQuery } = prisma;
let searchQuery = '';

if (search) {
searchQuery = `and ${column} LIKE {{search}}`;
searchQuery = getSearchQuery(column);
}

return rawQuery(
Expand Down

0 comments on commit 7899289

Please sign in to comment.