Skip to content

Commit

Permalink
RE-1240 fix eval attr path stack
Browse files Browse the repository at this point in the history
  • Loading branch information
ezerozen committed Jan 10, 2025
1 parent 331ff68 commit 8457a04
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions parser/jsonquery_visitor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,25 +224,20 @@ func (j *JsonQueryVisitorImpl) VisitCompareExpAttrPath(ctx *CompareExpAttrPathCo
return false
}
var currentOp Operation
switch j.leftOp.(type) {
switch j.rightOp.(type) {
case string:
currentOp = &StringOperation{BaseOperation: BaseOperation{config: j.config}}
case int, int32, int64:
currentOp = &IntOperation{BaseOperation: BaseOperation{config: j.config}}
case float32, float64:
currentOp = &FloatOperation{BaseOperation: BaseOperation{config: j.config}}
default:
if isNil(j.leftOp) {
j.setDebugErr(
newNestedError(ErrEvalOperandMissing, "Eval operand missing in input object").Set(ErrVals{
"attr_path": ctx.AttrPath().GetText(),
}),
)
return false
} else {
j.setErr(fmt.Errorf("invalid AttrPathValue"))
return false
}
j.setDebugErr(
newNestedError(ErrInvalidOperation, "Eval operand invalid type").Set(ErrVals{
"attr_path": ctx.AttrPathValue().GetText(),
}),
)
return false
}
var apply func(Operand, Operand) (bool, error)
switch ctx.op.GetTokenType() {
Expand Down Expand Up @@ -387,6 +382,7 @@ func (j *JsonQueryVisitorImpl) VisitAttrPath(ctx *AttrPathContext) interface{} {
item = j.item
}
if isNil(item) {
j.stack.clear()
return nil
}
m := item.(map[string]interface{})
Expand Down Expand Up @@ -416,6 +412,7 @@ func (j *JsonQueryVisitorImpl) VisitAttrPathValue(ctx *AttrPathValueContext) int
item = j.item
}
if isNil(item) {
j.stack.clear()
return nil
}
m := item.(map[string]interface{})
Expand Down

0 comments on commit 8457a04

Please sign in to comment.