diff --git a/pkg/yqlib/operator_alternative.go b/pkg/yqlib/operator_alternative.go index ca6ba2d7..06be05c9 100644 --- a/pkg/yqlib/operator_alternative.go +++ b/pkg/yqlib/operator_alternative.go @@ -2,7 +2,7 @@ package yqlib func alternativeOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) { log.Debugf("-- alternative") - return crossFunction(d, context.ReadOnlyClone(), expressionNode, alternativeFunc, true) + return crossFunction(d, context, expressionNode, alternativeFunc, true) } func alternativeFunc(d *dataTreeNavigator, context Context, lhs *CandidateNode, rhs *CandidateNode) (*CandidateNode, error) { diff --git a/pkg/yqlib/operator_alternative_test.go b/pkg/yqlib/operator_alternative_test.go index f4a986c4..3b852fa8 100644 --- a/pkg/yqlib/operator_alternative_test.go +++ b/pkg/yqlib/operator_alternative_test.go @@ -6,10 +6,13 @@ import ( var alternativeOperatorScenarios = []expressionScenario{ { + // to match jq - we do not use a readonly clone context on the LHS. skipDoc: true, expression: `.b // .c`, document: `a: bridge`, - expected: []string{}, + expected: []string{ + "D0, P[c], (!!null)::null\n", + }, }, { skipDoc: true,