From ebfc7212e29d1b317465afb3de7ac214755dd8a0 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Fri, 5 Feb 2021 14:40:16 +1100 Subject: [PATCH] Fixed merge dropping anchors --- pkg/yqlib/candidate_node.go | 4 ++-- pkg/yqlib/operator_multiply_test.go | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/yqlib/candidate_node.go b/pkg/yqlib/candidate_node.go index f3801f6..c868b61 100644 --- a/pkg/yqlib/candidate_node.go +++ b/pkg/yqlib/candidate_node.go @@ -63,8 +63,6 @@ func (n *CandidateNode) UpdateFrom(other *CandidateNode) { n.UpdateAttributesFrom(other) n.Node.Content = other.Node.Content n.Node.Value = other.Node.Value - n.Node.Alias = other.Node.Alias - n.Node.Anchor = other.Node.Anchor } func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode) { @@ -76,6 +74,8 @@ func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode) { } n.Node.Kind = other.Node.Kind n.Node.Tag = other.Node.Tag + n.Node.Alias = other.Node.Alias + n.Node.Anchor = other.Node.Anchor // merge will pickup the style of the new thing // when autocreating nodes diff --git a/pkg/yqlib/operator_multiply_test.go b/pkg/yqlib/operator_multiply_test.go index a9ef9ac..d1aefa0 100644 --- a/pkg/yqlib/operator_multiply_test.go +++ b/pkg/yqlib/operator_multiply_test.go @@ -13,6 +13,14 @@ var multiplyOperatorScenarios = []expressionScenario{ "D0, P[], (!!map)::{a: {also: me}, b: {also: me}}\n", }, }, + { + skipDoc: true, + document: `{a: &a { b: &b { c: &c cat } } }`, + expression: `{} * .`, + expected: []string{ + "D0, P[], (!!map)::{a: &a {b: &b {c: &c cat}}}\n", + }, + }, { skipDoc: true, document: `{a: 2, b: 5}`,