From e4d48bbc0d73f987ae140549e535c9d7b7502114 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 11 Jan 2021 14:44:53 +1100 Subject: [PATCH] Fixed collect at document level --- pkg/yqlib/operator_collect.go | 2 +- pkg/yqlib/operator_collect_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/yqlib/operator_collect.go b/pkg/yqlib/operator_collect.go index ffdfda62..b27b17cb 100644 --- a/pkg/yqlib/operator_collect.go +++ b/pkg/yqlib/operator_collect.go @@ -29,7 +29,7 @@ func CollectOperator(d *dataTreeNavigator, matchMap *list.List, pathNode *PathTr path = candidate.Path[:len(candidate.Path)-1] document = candidate.Document } - node.Content = append(node.Content, candidate.Node) + node.Content = append(node.Content, UnwrapDoc(candidate.Node)) } collectC := &CandidateNode{Node: node, Document: document, Path: path} diff --git a/pkg/yqlib/operator_collect_test.go b/pkg/yqlib/operator_collect_test.go index 9441ae10..4be76f81 100644 --- a/pkg/yqlib/operator_collect_test.go +++ b/pkg/yqlib/operator_collect_test.go @@ -13,6 +13,15 @@ var collectOperatorScenarios = []expressionScenario{ "D0, P[], (!!seq)::[]\n", }, }, + { + skipDoc: true, + document: "{a: apple}\n---\n{b: frog}", + + expression: `[.]`, + expected: []string{ + "D0, P[], (!!seq)::- {a: apple}\n- {b: frog}\n", + }, + }, { skipDoc: true, document: ``,