Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array with objects causes weird (broken) patches #42

Open
FrittenKeeZ opened this issue Apr 28, 2020 · 0 comments
Open

Array with objects causes weird (broken) patches #42

FrittenKeeZ opened this issue Apr 28, 2020 · 0 comments

Comments

@FrittenKeeZ
Copy link

FrittenKeeZ commented Apr 28, 2020

Comparing arrays with simple objects results in a weird broken patch.

import { diff } from 'jiff'

const $old = [{ id: 1 }]
const $new = [{ id: 2 }]
const $patch = diff($old, $new)
console.log($patch)

Expected outcome:

[
  { op: "test", path: "/0/id", value: 1 },
  { op: "replace", path: "/0/id", value: 2 },
]

Actual outcome:

[
  { op: "add", path: "/0", value: { id: 2 } },
  { op: "test", path: "/1", value: { id: 1 } },
  { op: "remove", path: "/1" },
]

I tried with a custom hasher method from another issue, but this didn't help.

Update: I switched to https://github.com/Starcounter-Jack/JSON-Patch which does exactly what I expected above.

kevinashworth added a commit to kevinashworth/Octave that referenced this issue Jul 18, 2020
And clean up some fragment stuff. Need theContacts, theProjects, contacts, projects.

We need `fast-json-patch` because of this brokenness:
cujojs/jiff#42
kevinashworth added a commit to kevinashworth/Octave that referenced this issue Jul 18, 2020
And clean up some fragment stuff. Need theContacts, theProjects, contacts, projects.

We need `fast-json-patch` because of this brokenness:
cujojs/jiff#42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant