From c63801a8a5502f5b16651885c64cb237c2e3321b Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Sat, 16 Jan 2021 14:56:52 +1100 Subject: [PATCH] thoughts --- pkg/yqlib/operator_multiply.go | 5 +++-- pkg/yqlib/operator_multiply_test.go | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/yqlib/operator_multiply.go b/pkg/yqlib/operator_multiply.go index 7d8d0787..4d98246c 100644 --- a/pkg/yqlib/operator_multiply.go +++ b/pkg/yqlib/operator_multiply.go @@ -74,9 +74,10 @@ func multiply(preferences multiplyPreferences) func(d *dataTreeNavigator, lhs *C return nil, err } return mergeObjects(d, newThing, rhs, preferences) - } else if lhs.Node.Tag == "!!int" && rhs.Node.Tag == "!!int" { - return lhs.CreateChild(nil, &yaml.Node{Kind: yaml.ScalarNode, Tag: "!!str", Value: "12"}), nil } + // else if lhs.Node.Tag == "!!int" && rhs.Node.Tag == "!!int" { + // return lhs.CreateChild(nil, &yaml.Node{Kind: yaml.ScalarNode, Tag: "!!str", Value: "12"}), nil + // } return nil, fmt.Errorf("Cannot multiply %v with %v", lhs.Node.Tag, rhs.Node.Tag) } } diff --git a/pkg/yqlib/operator_multiply_test.go b/pkg/yqlib/operator_multiply_test.go index ebca2f13..8635686d 100644 --- a/pkg/yqlib/operator_multiply_test.go +++ b/pkg/yqlib/operator_multiply_test.go @@ -4,6 +4,14 @@ import ( "testing" ) +// crossfunction: +// normal single document, treat each match separately: eval +// multiple documents, how do you do things between docs??? eval-all +// alternative +// collect and filter matches according to doc before running expression +// d0a d1a d0b d1b +// run it for (d0a d1a) x (d0b d1b) - noting that we dont do (d0a x d1a) nor (d0b d1b) +// I think this will work for eval-all correctly then.. var multiplyOperatorScenarios = []expressionScenario{ { skipDoc: true, @@ -13,6 +21,15 @@ var multiplyOperatorScenarios = []expressionScenario{ "D0, P[], (!!map)::{a: {also: me}, b: {also: me}}\n", }, }, + { + skipDoc: true, + document: `a: {also: [1]}`, + document2: `b: {also: me}`, + expression: `. * {"a" : .b}`, + expected: []string{ + "D0, P[], (!!map)::{a: {also: me}, b: {also: me}}\n", + }, + }, { skipDoc: true, expression: `{} * {"cat":"dog"}`,