This commit is contained in:
Aliaksandr Valialkin 2024-05-27 23:24:07 +02:00
parent 9903654e0f
commit dc245f82f3
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 5 additions and 2 deletions

View file

@ -27,8 +27,7 @@ func (fa *filterAnd) String() string {
a := make([]string, len(filters))
for i, f := range filters {
s := f.String()
switch f.(type) {
case *filterOr:
if _, ok := f.(*filterOr); ok {
s = "(" + s + ")"
}
a[i] = s

View file

@ -594,6 +594,10 @@ func TestParseQuerySuccess(t *testing.T) {
f(`NOT foo AND bar OR baz`, `!foo bar or baz`)
f(`NOT (foo AND bar) OR baz`, `!(foo bar) or baz`)
f(`foo OR bar AND baz`, `foo or bar baz`)
f(`foo bar or baz xyz`, `foo bar or baz xyz`)
f(`foo (bar or baz) xyz`, `foo (bar or baz) xyz`)
f(`foo or bar baz or xyz`, `foo or bar baz or xyz`)
f(`(foo or bar) (baz or xyz)`, `(foo or bar) (baz or xyz)`)
f(`(foo OR bar) AND baz`, `(foo or bar) baz`)
// parens