Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: regex operator is added in the string type for all data source #3362

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading