yq/pkg/yqlib/operator_pipe.go
2023-02-23 16:14:36 +11:00

23 lines
741 B
Go

package yqlib
func pipeOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
if expressionNode.LHS.Operation.OperationType == assignVariableOpType {
return variableLoop(d, context, expressionNode)
}
//lhs may update the variable context, we should pass that into the RHS
// BUT we still return the original context back (see jq)
// https://stedolan.github.io/jq/manual/#Variable/SymbolicBindingOperator:...as$identifier|...
lhs, err := d.GetMatchingNodes(context, expressionNode.LHS)
if err != nil {
return Context{}, err
}
rhs, err := d.GetMatchingNodes(lhs, expressionNode.RHS)
if err != nil {
return Context{}, err
}
return context.ChildContext(rhs.MatchingNodes), nil
}