Skip to content

Commit

Permalink
add parens
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Elliott <number101010@gmail.com>
  • Loading branch information
joe-elliott committed May 22, 2024
1 parent 84cdeb8 commit c76b339
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/traceql/ast_conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (o *BinaryOperation) extractConditions(request *FetchSpansRequest) {
case Attribute:
switch o.RHS.(type) {
case Static:
if o.RHS.(Static).Type == TypeNil && o.Op == OpNotEqual || !o.Op.isBoolean() { // the fetch layer can't build predicates on operators that are not boolean
if (o.RHS.(Static).Type == TypeNil && o.Op == OpNotEqual) || !o.Op.isBoolean() { // the fetch layer can't build predicates on operators that are not boolean
request.appendCondition(Condition{
Attribute: o.LHS.(Attribute),
Op: OpNone,
Expand Down Expand Up @@ -84,7 +84,7 @@ func (o *BinaryOperation) extractConditions(request *FetchSpansRequest) {
// 2 statics, don't need to send any conditions
return
case Attribute:
if o.LHS.(Static).Type == TypeNil && o.Op == OpNotEqual || !o.Op.isBoolean() { // the fetch layer can't build predicates on operators that are not boolean
if (o.LHS.(Static).Type == TypeNil && o.Op == OpNotEqual) || !o.Op.isBoolean() { // the fetch layer can't build predicates on operators that are not boolean
request.appendCondition(Condition{
Attribute: o.RHS.(Attribute),
Op: OpNone,
Expand Down
8 changes: 8 additions & 0 deletions pkg/traceql/ast_conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ func TestSpansetFilter_extractConditions(t *testing.T) {
},
allConditions: true,
},
{
query: `{ (.foo = 2) && (.bar / 1 > 3) }`,
conditions: []Condition{
newCondition(NewAttribute("foo"), OpEqual, NewStaticInt(2)),
newCondition(NewAttribute("bar"), OpNone),
},
allConditions: true,
},
}
for _, tt := range tests {
t.Run(tt.query, func(t *testing.T) {
Expand Down

0 comments on commit c76b339

Please sign in to comment.