Skip to content

Commit 2c2487c

Browse files
committed
Fixing Regression in #2353, #2359, #2325
1 parent 2c7cce0 commit 2c2487c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

pkg/yqlib/operator_add_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,13 @@ var addOperatorScenarios = []expressionScenario{
310310
"D0, P[], (!!map)::a: !cat Saturday, 15-Dec-01 at 6:00AM GMT\n",
311311
},
312312
},
313+
{
314+
skipDoc: true,
315+
description: "empty add shouldn't add",
316+
document: `[]`,
317+
expression: `.[] | (.a + "cat")`,
318+
expected: []string{},
319+
},
313320
{
314321
skipDoc: true,
315322
description: "Add to empty",

pkg/yqlib/operators.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func doCrossFunc(d *dataTreeNavigator, context Context, expressionNode *Expressi
118118
}
119119
log.Debugf("crossFunction LHS len: %v", lhs.MatchingNodes.Len())
120120

121-
if prefs.CalcWhenEmpty && lhs.MatchingNodes.Len() == 0 {
121+
if prefs.CalcWhenEmpty && context.MatchingNodes.Len() > 0 && lhs.MatchingNodes.Len() == 0 {
122122
err := resultsForRHS(d, context, nil, prefs, expressionNode.RHS, results)
123123
if err != nil {
124124
return Context{}, err

project-words.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,5 @@ zabbix
255255
tonumber
256256
noyaml
257257
nolint
258-
shortfile
258+
shortfile
259+
Unmarshalling

0 commit comments

Comments
 (0)