Skip to content

Commit fd2ccdf

Browse files
committed
Add ability to escape characters
1 parent 1840fc0 commit fd2ccdf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/database/schemas.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ function getFilterClause(againstColumn: string, filter: string, noAnd?: boolean)
2626

2727
let clause = `${noAnd ? '' : 'AND'} UPPER(${againstColumn})`;
2828
let parameters: BasicColumnType[] = [];
29+
let hasEscapeChar = false;
30+
31+
if (filter.indexOf('\\\\') >= 0) {
32+
hasEscapeChar = true;
33+
filter = filter.replace(/\\\\/g, '@');
34+
}
2935

3036
if (filter.endsWith(`*`)) {
3137
clause += ` LIKE ? CONCAT '%'`;
@@ -35,7 +41,9 @@ function getFilterClause(againstColumn: string, filter: string, noAnd?: boolean)
3541
parameters.push(filter.toUpperCase());
3642
}
3743

38-
// clause += ` ESCAPE '${SQL_ESCAPE_CHAR}'`;
44+
if (hasEscapeChar) {
45+
clause += ` ESCAPE '@'`;
46+
}
3947

4048
return {
4149
clause,

0 commit comments

Comments
 (0)