Fixed value operator bug #1515

This commit is contained in:
Mike Farah
2023-01-12 15:11:45 +11:00
parent fcda053d73
commit d7da0cca3c
7 changed files with 55 additions and 7 deletions
+25 -1
View File
@@ -1,6 +1,30 @@
package yqlib
import "container/list"
func referenceOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
return context.SingleChildContext(expressionNode.Operation.CandidateNode), nil
}
func valueOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
log.Debug("value = %v", expressionNode.Operation.CandidateNode.Node.Value)
return context.SingleChildContext(expressionNode.Operation.CandidateNode), nil
if context.MatchingNodes.Len() == 0 {
clone, err := expressionNode.Operation.CandidateNode.Copy()
if err != nil {
return Context{}, err
}
return context.SingleChildContext(clone), nil
}
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
clone, err := expressionNode.Operation.CandidateNode.Copy()
if err != nil {
return Context{}, err
}
results.PushBack(clone)
}
return context.ChildContext(results), nil
}