Fixed tag operator for top level node

This commit is contained in:
Mike Farah 2021-01-12 09:45:57 +11:00
parent 90ec05be54
commit e28df367eb
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

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