mirror of
https://github.com/SigNoz/signoz.git
synced 2026-02-03 08:33:26 +00:00
fix: added fix for free text with quick filter issue (#9768)
* fix: added fix free text with quick filter issue * chore: removed debug console log * chore: pr review changes
This commit is contained in:
@@ -163,6 +163,10 @@ function formatSingleValueForFilter(
|
||||
if (trimmed === 'true' || trimmed === 'false') {
|
||||
return trimmed === 'true';
|
||||
}
|
||||
|
||||
if (isQuoted(value)) {
|
||||
return unquote(value);
|
||||
}
|
||||
}
|
||||
|
||||
// Return non-string values as-is, or string values that couldn't be converted
|
||||
|
||||
@@ -61,6 +61,58 @@ describe('extractQueryPairs', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('should test for filter expression with freeText', () => {
|
||||
const input = "disconnected deployment.env not in ['mq-kafka']";
|
||||
const result = extractQueryPairs(input);
|
||||
expect(result).toEqual([
|
||||
{
|
||||
key: 'disconnected',
|
||||
operator: '',
|
||||
valueList: [],
|
||||
valuesPosition: [],
|
||||
hasNegation: false,
|
||||
isMultiValue: false,
|
||||
value: undefined,
|
||||
position: {
|
||||
keyStart: 0,
|
||||
keyEnd: 11,
|
||||
operatorStart: 0,
|
||||
operatorEnd: 0,
|
||||
negationStart: 0,
|
||||
negationEnd: 0,
|
||||
valueStart: undefined,
|
||||
valueEnd: undefined,
|
||||
},
|
||||
isComplete: false,
|
||||
},
|
||||
{
|
||||
key: 'deployment.env',
|
||||
operator: 'in',
|
||||
value: "['mq-kafka']",
|
||||
valueList: ["'mq-kafka'"],
|
||||
valuesPosition: [
|
||||
{
|
||||
start: 36,
|
||||
end: 45,
|
||||
},
|
||||
],
|
||||
hasNegation: true,
|
||||
isMultiValue: true,
|
||||
position: {
|
||||
keyStart: 13,
|
||||
keyEnd: 26,
|
||||
operatorStart: 32,
|
||||
operatorEnd: 33,
|
||||
valueStart: 35,
|
||||
valueEnd: 46,
|
||||
negationStart: 28,
|
||||
negationEnd: 30,
|
||||
},
|
||||
isComplete: true,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('should extract IN with numeric list inside parentheses', () => {
|
||||
const input = 'id IN (1, 2, 3)';
|
||||
const result = extractQueryPairs(input);
|
||||
|
||||
@@ -1339,8 +1339,7 @@ export function extractQueryPairs(query: string): IQueryPair[] {
|
||||
else if (
|
||||
currentPair &&
|
||||
currentPair.key &&
|
||||
(isConjunctionToken(token.type) ||
|
||||
(token.type === FilterQueryLexer.KEY && isQueryPairComplete(currentPair)))
|
||||
(isConjunctionToken(token.type) || token.type === FilterQueryLexer.KEY)
|
||||
) {
|
||||
queryPairs.push({
|
||||
key: currentPair.key,
|
||||
|
||||
Reference in New Issue
Block a user