Added support for adding objects

This commit is contained in:
Mike Farah
2022-01-23 11:35:44 +11:00
parent 9b66e0a094
commit 9b1a7bf451
4 changed files with 95 additions and 19 deletions
+9
View File
@@ -144,6 +144,15 @@ var addOperatorScenarios = []expressionScenario{
"D0, P[], (!!str)::cat\n",
},
},
{
description: "Add maps to shallow merge",
subdescription: "Adding objects together shallow merges them. Use `*` to deeply merge.",
document: "a: {thing: {name: Astuff, value: x}, a1: cool}\nb: {thing: {name: Bstuff, legs: 3}, b1: neat}",
expression: `.a += .b`,
expected: []string{
"D0, P[], (doc)::a: {thing: {name: Bstuff, legs: 3}, a1: cool, b1: neat}\nb: {thing: {name: Bstuff, legs: 3}, b1: neat}\n",
},
},
{
description: "Custom types: that are really strings",
subdescription: "When custom tags are encountered, yq will try to decode the underlying type.",