add regex operators

This commit is contained in:
Francis Cao committed 2026-02-20 13:43:16 -08:00
1 parent 67626652f9
commit f2cf071523
59 files changed
+136 -2

No files matched your search

+4
View File
@@ -82,6 +82,10 @@ function mapFilter(column: string, operator: string, name: string, type: string
return `positionCaseInsensitive(${column}, ${value}) > 0`;
case OPERATORS.doesNotContain:
return `positionCaseInsensitive(${column}, ${value}) = 0`;
case OPERATORS.regex:
return `match(${column}, ${value})`;
case OPERATORS.notRegex:
return `not match(${column}, ${value})`;
default:
return '';
}
+2
View File
@@ -129,6 +129,8 @@ export const OPERATORS = {
notSet: 'ns',
contains: 'c',
doesNotContain: 'dnc',
regex: 're',
notRegex: 'nre',
true: 't',
false: 'f',
greaterThan: 'gt',
+6 -1
View File
@@ -31,7 +31,12 @@ export function isEqualsOperator(operator: any) {
}
export function isSearchOperator(operator: any) {
return [OPERATORS.contains, OPERATORS.doesNotContain].includes(operator);
return [
OPERATORS.contains,
OPERATORS.doesNotContain,
OPERATORS.regex,
OPERATORS.notRegex,
].includes(operator);
}
export function filtersObjectToArray(filters: QueryFilters, options: QueryOptions = {}): Filter[] {
+4
View File
@@ -89,6 +89,10 @@ function mapFilter(column: string, operator: string, name: string, type: string
return `${table}.${column} ilike ${value}`;
case OPERATORS.doesNotContain:
return `${table}.${column} not ilike ${value}`;
case OPERATORS.regex:
return `${table}.${column} ~ ${value}`;
case OPERATORS.notRegex:
return `${table}.${column} !~ ${value}`;
default:
return '';
}
+2
View File
@@ -143,6 +143,8 @@ export const operatorParam = z.enum([
'ns',
'c',
'dnc',
're',
'nre',
't',
'f',
'gt',