mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Fixes #870
This commit is contained in:
parent
542efd8928
commit
b0074f5eba
@ -1,24 +1,27 @@
|
|||||||
package yqlib
|
package yqlib
|
||||||
|
|
||||||
|
func assignUpdateFunc(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) {
|
||||||
|
rhs.Node = unwrapDoc(rhs.Node)
|
||||||
|
lhs.UpdateFrom(rhs)
|
||||||
|
return lhs, nil
|
||||||
|
}
|
||||||
|
|
||||||
func assignUpdateOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
func assignUpdateOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
||||||
lhs, err := d.GetMatchingNodes(context, expressionNode.Lhs)
|
lhs, err := d.GetMatchingNodes(context, expressionNode.Lhs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Context{}, err
|
return Context{}, err
|
||||||
}
|
}
|
||||||
var rhs Context
|
|
||||||
if !expressionNode.Operation.UpdateAssign {
|
if !expressionNode.Operation.UpdateAssign {
|
||||||
rhs, err = d.GetMatchingNodes(context.ReadOnlyClone(), expressionNode.Rhs)
|
// this works because we already ran against LHS with an editable context.
|
||||||
if err != nil {
|
_, err := crossFunction(d, context.ReadOnlyClone(), expressionNode, assignUpdateFunc, false)
|
||||||
return Context{}, err
|
return context, err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for el := lhs.MatchingNodes.Front(); el != nil; el = el.Next() {
|
for el := lhs.MatchingNodes.Front(); el != nil; el = el.Next() {
|
||||||
candidate := el.Value.(*CandidateNode)
|
candidate := el.Value.(*CandidateNode)
|
||||||
|
|
||||||
if expressionNode.Operation.UpdateAssign {
|
rhs, err := d.GetMatchingNodes(context.SingleChildContext(candidate), expressionNode.Rhs)
|
||||||
rhs, err = d.GetMatchingNodes(context.SingleChildContext(candidate), expressionNode.Rhs)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Context{}, err
|
return Context{}, err
|
||||||
|
@ -95,9 +95,12 @@ func crossFunction(d *dataTreeNavigator, context Context, expressionNode *Expres
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if evaluateAllTogether {
|
if evaluateAllTogether {
|
||||||
|
log.Debug("crossFunction evaluateAllTogether!")
|
||||||
return doCrossFunc(d, context, expressionNode, calculation, calcWhenEmpty)
|
return doCrossFunc(d, context, expressionNode, calculation, calcWhenEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debug("crossFunction evaluate apart!")
|
||||||
|
|
||||||
for matchEl := context.MatchingNodes.Front(); matchEl != nil; matchEl = matchEl.Next() {
|
for matchEl := context.MatchingNodes.Front(); matchEl != nil; matchEl = matchEl.Next() {
|
||||||
innerResults, err := doCrossFunc(d, context.SingleChildContext(matchEl.Value.(*CandidateNode)), expressionNode, calculation, calcWhenEmpty)
|
innerResults, err := doCrossFunc(d, context.SingleChildContext(matchEl.Value.(*CandidateNode)), expressionNode, calculation, calcWhenEmpty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user