Added contains operator

This commit is contained in:
Mike Farah
2021-09-15 15:18:10 +10:00
parent 5f154eb1b6
commit 2db8140d7f
9 changed files with 339 additions and 2 deletions
+16
View File
@@ -11,6 +11,22 @@ var withOperatorScenarios = []expressionScenario{
"D0, P[], (doc)::a: {deeply: {nested: 'newValue'}}\n",
},
},
{
description: "Update multiple deeply nested properties",
document: `a: {deeply: {nested: value, other: thing}}`,
expression: `with(.a.deeply ; .nested = "newValue" | .other= "newThing")`,
expected: []string{
"D0, P[], (doc)::a: {deeply: {nested: newValue, other: newThing}}\n",
},
},
{
description: "Update array elements relatively",
document: `myArray: [{a: apple},{a: banana}]`,
expression: `with(.myArray[] ; .b = .a + " yum")`,
expected: []string{
"D0, P[], (doc)::myArray: [{a: apple, b: apple yum}, {a: banana, b: banana yum}]\n",
},
},
}
func TestWithOperatorScenarios(t *testing.T) {