Skip to content

Commit 7c83c0a

Browse files
committed
typed: Replace duplicates rather than merging
1 parent 01d60e1 commit 7c83c0a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: typed/merge.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ func (w *mergingWalker) indexListPathElements(t *schema.List, list value.List) (
300300
// this element.
301301
continue
302302
}
303-
if _, found := observed.Get(pe); !found {
303+
if _, found := observed.Get(pe); found {
304+
observed.Insert(pe, value.NewValueInterface(nil))
305+
} else {
304306
observed.Insert(pe, child)
305307
}
306308
pes = append(pes, pe)

Diff for: typed/merge_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,8 @@ var mergeCases = []mergeTestCase{{
469469
`{"atomicList":["a","a"]}`,
470470
}, {
471471
`{"list":[{"key":"a","id":1,"bv":true},{"key":"b","id":2},{"key":"a","id":1,"bv":false,"nv":2}]}`,
472-
`{"list":[{"key":"a","id":1,"nv":3}, {"key":"c","id":3},{"key":"b","id":2}]}`,
473-
`{"list":[{"key":"a","id":1,"bv":true,"nv":3},{"key":"c","id":3},{"key":"b","id":2}]}`,
472+
`{"list":[{"key":"a","id":1,"nv":3},{"key":"c","id":3},{"key":"b","id":2}]}`,
473+
`{"list":[{"key":"a","id":1,"nv":3},{"key":"c","id":3},{"key":"b","id":2}]}`,
474474
}, {
475475
`{"list":[{"key":"a","id":1,"nv":1},{"key":"a","id":1,"nv":2}]}`,
476476
`{"list":[]}`,

0 commit comments

Comments
 (0)