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}`,