From 24538c0cc779f31ae07b2344521533e81ce9ebaf Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Tue, 12 Jan 2021 09:45:57 +1100 Subject: [PATCH] Fixed tag operator for top level node --- pkg/yqlib/operator_tag.go | 2 +- pkg/yqlib/operator_tag_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/yqlib/operator_tag.go b/pkg/yqlib/operator_tag.go index 52d3ccef..f8a37063 100644 --- a/pkg/yqlib/operator_tag.go +++ b/pkg/yqlib/operator_tag.go @@ -41,7 +41,7 @@ func assignTagOperator(d *dataTreeNavigator, matchingNodes *list.List, pathNode tag = rhs.Front().Value.(*CandidateNode).Node.Value } } - candidate.Node.Tag = tag + UnwrapDoc(candidate.Node).Tag = tag } return matchingNodes, nil diff --git a/pkg/yqlib/operator_tag_test.go b/pkg/yqlib/operator_tag_test.go index b64afadd..1d47c501 100644 --- a/pkg/yqlib/operator_tag_test.go +++ b/pkg/yqlib/operator_tag_test.go @@ -26,6 +26,14 @@ var tagOperatorScenarios = []expressionScenario{ "D0, P[], (!!str)::'!!map'\n", }, }, + { + skipDoc: true, + document: `32`, + expression: `. tag= "!!str"`, + expected: []string{ + "D0, P[], (doc)::\"32\"\n", + }, + }, { description: "Set custom tag", document: `{a: str}`,