Skip to content

Commit 01dd7fd

Browse files
authored
Add check for quotes after midConditional (#2803)
1 parent 03347d6 commit 01dd7fd

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/lib/utilities/query/tokenize.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ describe('tokenize', () => {
6363
]);
6464
});
6565

66+
it('should tokenize the not equal to conditional', () => {
67+
const result = [
68+
'WorkflowId',
69+
'=',
70+
'Hello',
71+
'and',
72+
'WorkflowType',
73+
'!=',
74+
'World',
75+
];
76+
let query = '`WorkflowId`="Hello" and `WorkflowType`!="World"';
77+
expect(tokenize(query)).toEqual(result);
78+
query = '`WorkflowId` = "Hello" and `WorkflowType` != "World"';
79+
expect(tokenize(query)).toEqual(result);
80+
});
81+
6682
it('should tokenize the customAttributesWithSpacesQuery', () => {
6783
const query = customAttributesWithSpacesQuery;
6884

@@ -153,6 +169,12 @@ describe('tokenize', () => {
153169
expect(tokenize(query)).toEqual(['WorkflowType', 'STARTS_WITH', 'Hello']);
154170
});
155171

172+
it('should tokenize the startsWithQuery without spaces', () => {
173+
const query = '`WorkflowType`STARTS_WITH"Hello"';
174+
175+
expect(tokenize(query)).toEqual(['WorkflowType', 'STARTS_WITH', 'Hello']);
176+
});
177+
156178
it('should tokenize the startsWithInQuery for values with IN conditional in them', () => {
157179
const query = '`WorkflowType` STARTS_WITH "Inspect"';
158180

src/lib/utilities/query/tokenize.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ export const tokenize = (string: string): Tokens => {
8484
continue;
8585
} else if (
8686
isConditional(midConditional) &&
87-
(isSpace(string[cursor + 2]) || isParenthesis(string[cursor + 2]))
87+
(isSpace(string[cursor + 2]) ||
88+
isQuote(string[cursor + 2]) ||
89+
isParenthesis(string[cursor + 2]))
8890
) {
89-
// To prevent false positives like "inspect" being a "in" conditional, check for space or parenthesis after the midConditional
91+
// To prevent false positives like "inspect" being a "in" conditional, check for space, quote, or parenthesis after the midConditional
9092
buffer += midConditional;
9193
addBufferToTokens();
9294
cursor += 2;

0 commit comments

Comments
 (0)