lib/logstorage: allow using - instead of ! in front of (...)

This commit is contained in:
Aliaksandr Valialkin 2024-09-29 11:12:22 +02:00
parent fce6fc745a
commit b7a3d575da
No known key found for this signature in database
GPG Key ID: 52C003EE2BCDB9EB
2 changed files with 3 additions and 1 deletions

View File

@ -840,7 +840,7 @@ func parseGenericFilter(lex *lexer, fieldName string) (filter, error) {
} }
return f, nil return f, nil
case lex.isKeyword("("): case lex.isKeyword("("):
if !lex.isSkippedSpace && !lex.isPrevToken("", ":", "(", "!", "not") { if !lex.isSkippedSpace && !lex.isPrevToken("", ":", "(", "!", "-", "not") {
return nil, fmt.Errorf("missing whitespace before the search word %q", lex.prevToken) return nil, fmt.Errorf("missing whitespace before the search word %q", lex.prevToken)
} }
return parseParensFilter(lex, fieldName) return parseParensFilter(lex, fieldName)

View File

@ -646,6 +646,8 @@ func TestParseQuerySuccess(t *testing.T) {
f(`not(foo)`, `!foo`) f(`not(foo)`, `!foo`)
f(`not (foo)`, `!foo`) f(`not (foo)`, `!foo`)
f(`not ( foo or bar )`, `!(foo or bar)`) f(`not ( foo or bar )`, `!(foo or bar)`)
f(`!(foo or bar)`, `!(foo or bar)`)
f(`-(foo or bar)`, `!(foo or bar)`)
f(`foo:!""`, `!foo:""`) f(`foo:!""`, `!foo:""`)
f("_msg:foo", "foo") f("_msg:foo", "foo")
f("'foo:bar'", `"foo:bar"`) f("'foo:bar'", `"foo:bar"`)