mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 05:38:04 +00:00
Fixes issue when update against self #1869
This commit is contained in:
parent
4b8c8506a5
commit
3d64bdadc1
@ -368,7 +368,10 @@ func (n *CandidateNode) doCopy(cloneContent bool) *CandidateNode {
|
||||
|
||||
// updates this candidate from the given candidate node
|
||||
func (n *CandidateNode) UpdateFrom(other *CandidateNode, prefs assignPreferences) {
|
||||
|
||||
if n == other {
|
||||
log.Debugf("UpdateFrom, no need to update from myself.")
|
||||
return
|
||||
}
|
||||
// if this is an empty map or empty array, use the style of other node.
|
||||
if (n.Kind != ScalarNode && len(n.Content) == 0) ||
|
||||
// if the tag has changed (e.g. from str to bool)
|
||||
|
@ -17,6 +17,15 @@ var assignOperatorScenarios = []expressionScenario{
|
||||
"D0, P[], ()::a:\n b: cat\nx: frog\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Create yaml file",
|
||||
document: "a: {b: 3}",
|
||||
expression: `.a |= .`,
|
||||
skipDoc: true,
|
||||
expected: []string{
|
||||
"D0, P[], (!!map)::a: {b: 3}\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
document: "{}",
|
||||
|
Loading…
Reference in New Issue
Block a user