Skip to content

Commit b35d54d

Browse files
committed
patched binary walk
1 parent b44fda8 commit b35d54d

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

expr/binary.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ func (b *Binary) Walk(fn func(ident node.Node, values *Values, operator, parentO
4040
return err
4141
}
4242
}
43+
if y, ok := b.Y.(*Parenthesis); ok {
44+
if nested, ok := y.X.(*Binary); ok {
45+
if err := nested.walk(fn, b.Op); err != nil {
46+
return err
47+
}
48+
}
49+
}
4350
return nil
4451
}
4552
return b.walk(fn, "")

query_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
func TestBinaryWalk(t *testing.T) {
16-
query, _ := ParseQuery("SELECT * FROM t WHERE a = 1 AND b = 2 AND (c IN(1,2))")
16+
query, _ := ParseQuery("SELECT * FROM t WHERE a = 1 AND (c IN(1,2))")
1717
binary, ok := query.Qualify.X.(*expr.Binary)
1818
if !assert.True(t, ok) {
1919
return
@@ -23,7 +23,7 @@ func TestBinaryWalk(t *testing.T) {
2323
actualColumns = append(actualColumns, Stringify(ident))
2424
return nil
2525
})
26-
assert.EqualValues(t, []string{"a", "b", "c"}, actualColumns)
26+
assert.EqualValues(t, []string{"a", "c"}, actualColumns)
2727

2828
}
2929

0 commit comments

Comments
 (0)