Skip to content

Commit

Permalink
typed: Replace duplicates rather than merging
Browse files Browse the repository at this point in the history
  • Loading branch information
apelisse committed Oct 18, 2023
1 parent 01d60e1 commit 7c83c0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion typed/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ func (w *mergingWalker) indexListPathElements(t *schema.List, list value.List) (
// this element.
continue
}
if _, found := observed.Get(pe); !found {
if _, found := observed.Get(pe); found {
observed.Insert(pe, value.NewValueInterface(nil))
} else {
observed.Insert(pe, child)
}
pes = append(pes, pe)
Expand Down
4 changes: 2 additions & 2 deletions typed/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ var mergeCases = []mergeTestCase{{
`{"atomicList":["a","a"]}`,
}, {
`{"list":[{"key":"a","id":1,"bv":true},{"key":"b","id":2},{"key":"a","id":1,"bv":false,"nv":2}]}`,
`{"list":[{"key":"a","id":1,"nv":3}, {"key":"c","id":3},{"key":"b","id":2}]}`,
`{"list":[{"key":"a","id":1,"bv":true,"nv":3},{"key":"c","id":3},{"key":"b","id":2}]}`,
`{"list":[{"key":"a","id":1,"nv":3},{"key":"c","id":3},{"key":"b","id":2}]}`,
`{"list":[{"key":"a","id":1,"nv":3},{"key":"c","id":3},{"key":"b","id":2}]}`,
}, {
`{"list":[{"key":"a","id":1,"nv":1},{"key":"a","id":1,"nv":2}]}`,
`{"list":[]}`,
Expand Down

0 comments on commit 7c83c0a

Please sign in to comment.