From 8941573c1a7b06c88b138bc17f0d22c5e8b072c3 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Thu, 2 Sep 2021 15:36:23 +1000 Subject: [PATCH] Fixing alternative op bug #930 --- pkg/yqlib/operator_alternative.go | 2 +- pkg/yqlib/operator_alternative_test.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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,