Skip to content

Commit 3f9eee7

Browse files
committed
fix(flow): enhance regex for logical operators in SQL parsing
1 parent 2710084 commit 3f9eee7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/components/flow/composables/useParseWhere.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createRandomString } from '@emqx/shared-ui-utils'
22
import { FilterLogicalOperator, RULE_LOGICAL_OPERATORS } from '@emqx/shared-ui-constants'
3-
import { cloneDeep } from 'lodash'
3+
import { cloneDeep, escapeRegExp } from 'lodash'
44
import type { FilterFormData, FilterItem } from '../types'
55

66
const parseWhere = (sql: string): FilterFormData | FilterItem => {
@@ -73,6 +73,12 @@ const splitCondition = (sql: string, separator: string) => {
7373
const separator = new RegExp(
7474
`(${cloneDeep(RULE_LOGICAL_OPERATORS)
7575
.sort((a, b) => b.length - a.length)
76+
.map((item) => {
77+
if (/^\w+$/.test(item)) {
78+
return `\\b${escapeRegExp(item)}\\b`
79+
}
80+
return escapeRegExp(item)
81+
})
7682
.join('|')})`,
7783
'i',
7884
)

0 commit comments

Comments
 (0)