diff --git a/pkg/yqlib/operator_alternative_test.go b/pkg/yqlib/operator_alternative_test.go index 902fe170..9a57a052 100644 --- a/pkg/yqlib/operator_alternative_test.go +++ b/pkg/yqlib/operator_alternative_test.go @@ -5,6 +5,12 @@ import ( ) var alternativeOperatorScenarios = []expressionScenario{ + { + skipDoc: true, + expression: `.b // .c`, + document: `a: bridge`, + expected: []string{}, + }, { skipDoc: true, expression: `(.b // "hello") as $x`, diff --git a/pkg/yqlib/operator_booleans_test.go b/pkg/yqlib/operator_booleans_test.go index d94eee5a..2f3477d2 100644 --- a/pkg/yqlib/operator_booleans_test.go +++ b/pkg/yqlib/operator_booleans_test.go @@ -12,6 +12,14 @@ var booleanOperatorScenarios = []expressionScenario{ "D0, P[], (!!bool)::true\n", }, }, + { + skipDoc: true, + document: "b: hi", + expression: `.a or .c`, + expected: []string{ + "D0, P[], (!!bool)::false\n", + }, + }, { skipDoc: true, document: "b: hi", diff --git a/pkg/yqlib/operator_equals_test.go b/pkg/yqlib/operator_equals_test.go index 07cd3cf0..e815f89d 100644 --- a/pkg/yqlib/operator_equals_test.go +++ b/pkg/yqlib/operator_equals_test.go @@ -5,6 +5,13 @@ import ( ) var equalsOperatorScenarios = []expressionScenario{ + { + skipDoc: true, + expression: ".a == .b", + expected: []string{ + "D0, P[], (!!bool)::true\n", + }, + }, { skipDoc: true, document: "cat", diff --git a/pkg/yqlib/operators.go b/pkg/yqlib/operators.go index 1242b6f4..1b0731d4 100644 --- a/pkg/yqlib/operators.go +++ b/pkg/yqlib/operators.go @@ -31,7 +31,9 @@ func resultsForRhs(d *dataTreeNavigator, context Context, lhsCandidate *Candidat if err != nil { return err } - results.PushBack(resultCandidate) + if resultCandidate != nil { + results.PushBack(resultCandidate) + } return nil } @@ -42,7 +44,9 @@ func resultsForRhs(d *dataTreeNavigator, context Context, lhsCandidate *Candidat if err != nil { return err } - results.PushBack(resultCandidate) + if resultCandidate != nil { + results.PushBack(resultCandidate) + } } return nil }