2020-12-01 06:58:07 +00:00
|
|
|
package yqlib
|
|
|
|
|
2021-02-02 07:17:59 +00:00
|
|
|
func pipeOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
2020-12-01 06:58:07 +00:00
|
|
|
|
2021-02-02 07:17:59 +00:00
|
|
|
//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|...
|
|
|
|
|
2022-02-07 00:55:55 +00:00
|
|
|
lhs, err := d.GetMatchingNodes(context, expressionNode.LHS)
|
2021-02-02 07:17:59 +00:00
|
|
|
if err != nil {
|
|
|
|
return Context{}, err
|
|
|
|
}
|
2022-02-07 00:55:55 +00:00
|
|
|
rhs, err := d.GetMatchingNodes(lhs, expressionNode.RHS)
|
2020-12-01 06:58:07 +00:00
|
|
|
if err != nil {
|
2021-02-02 07:17:59 +00:00
|
|
|
return Context{}, err
|
2020-12-01 06:58:07 +00:00
|
|
|
}
|
2021-02-02 07:17:59 +00:00
|
|
|
return context.ChildContext(rhs.MatchingNodes), nil
|
2020-12-01 06:58:07 +00:00
|
|
|
}
|