mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 13:48:06 +00:00
Fixes append map bug when key matches value in existing map #1200
This commit is contained in:
parent
26529fae94
commit
67c79b7cb1
@ -183,7 +183,7 @@ func addMaps(target *CandidateNode, lhsC *CandidateNode, rhsC *CandidateNode) {
|
||||
key := rhs.Content[index]
|
||||
value := rhs.Content[index+1]
|
||||
log.Debug("finding %v", key.Value)
|
||||
indexInLHS := findInArray(target.Node, key)
|
||||
indexInLHS := findKeyInMap(target.Node, key)
|
||||
log.Debug("indexInLhs %v", indexInLHS)
|
||||
if indexInLHS < 0 {
|
||||
// not in there, append it
|
||||
|
@ -14,6 +14,14 @@ var addOperatorScenarios = []expressionScenario{
|
||||
"D0, P[1 a], (!!int)::3\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
document: `a: key`,
|
||||
expression: `. += {"key": "b"}`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!map)::a: key\nkey: b\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
document: `[[c], [b]]`,
|
||||
|
Loading…
Reference in New Issue
Block a user