Skip to content

Commit

Permalink
feat: regex operator is added in the string type for all data source (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
palashgdev committed Aug 18, 2023
1 parent c8bad4f commit 458cff3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions frontend/src/constants/queryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ export const OPERATORS = {
NIN: 'NOT_IN',
LIKE: 'LIKE',
NLIKE: 'NOT_LIKE',
REGEX: 'REGEX',
NREGEX: 'NOT_REGEX',
'=': '=',
'!=': '!=',
EXISTS: 'EXISTS',
Expand All @@ -284,6 +286,8 @@ export const QUERY_BUILDER_OPERATORS_BY_TYPES = {
OPERATORS.NOT_CONTAINS,
OPERATORS.EXISTS,
OPERATORS.NOT_EXISTS,
OPERATORS.REGEX,
OPERATORS.NREGEX,
],
int64: [
OPERATORS['='],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { OPERATORS } from 'constants/queryBuilder';
// eslint-disable-next-line import/no-extraneous-dependencies
import * as Papa from 'papaparse';

import { orderByValueDelimiter } from '../OrderByFilter/utils';

export const tagRegexp = /([a-zA-Z0-9_.:@$()\-/\\]+)\s*(!=|=|<=|<|>=|>|IN|NOT_IN|LIKE|NOT_LIKE|EXISTS|NOT_EXISTS|CONTAINS|NOT_CONTAINS)\s*([\s\S]*)/g;
export const tagRegexp = /([a-zA-Z0-9_.:@$()\-/\\]+)\s*(!=|=|<=|<|>=|>|IN|NOT_IN|LIKE|NOT_LIKE|REGEX|NOT_REGEX|EXISTS|NOT_EXISTS|CONTAINS|NOT_CONTAINS)\s*([\s\S]*)/g;

export function isInNInOperator(value: string): boolean {
return value === OPERATORS.IN || value === OPERATORS.NIN;
Expand Down Expand Up @@ -56,6 +55,10 @@ export function getOperatorValue(op: string): string {
return 'in';
case 'NOT_IN':
return 'nin';
case OPERATORS.REGEX:
return 'regex';
case OPERATORS.NREGEX:
return 'nregex';
case 'LIKE':
return 'like';
case 'NOT_LIKE':
Expand All @@ -81,6 +84,10 @@ export function getOperatorFromValue(op: string): string {
return 'NOT_IN';
case 'like':
return 'LIKE';
case 'regex':
return OPERATORS.REGEX;
case 'nregex':
return OPERATORS.NREGEX;
case 'nlike':
return 'NOT_LIKE';
case 'exists':
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/hooks/queryBuilder/useOperatorType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const operatorTypeMapper: Record<string, OperatorType> = {
[OPERATORS['>']]: 'SINGLE_VALUE',
[OPERATORS.LIKE]: 'SINGLE_VALUE',
[OPERATORS.NLIKE]: 'SINGLE_VALUE',
[OPERATORS.REGEX]: 'SINGLE_VALUE',
[OPERATORS.NREGEX]: 'SINGLE_VALUE',
[OPERATORS.CONTAINS]: 'SINGLE_VALUE',
[OPERATORS.NOT_CONTAINS]: 'SINGLE_VALUE',
[OPERATORS['=']]: 'SINGLE_VALUE',
Expand Down

0 comments on commit 458cff3

Please sign in to comment.