-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add patch inversion #9
Comments
Potential issues:
[{ "op":"test", "path":"/foo", "value":"bar" }, { "op":"replace", "path":"/foo", "value":"baz"}] Inverting the patch yields a post-condition test that [{ "op":"replace", "path":"/foo", "value":"bar"}, { "op":"test", "path":"/foo", "value":"bar" }] Of course, for the purposes of that example, I've ignored the fact that |
Hmmm, perhaps For example, this patch cannot be inverted: [{ "op":"remove", "path":"/foo"}] However, by adding a test: [{ "op":"test", "path":"/foo", "value":"bar" }, { "op":"remove", "path":"/foo"}] We now know the value that is being removed: if the value of [{ "op":"add", "path":"/foo", "value":"bar"}, { "op":"test", "path":"/foo", "value":"bar" }] which adds the previously removed I think we would have to put that responsibility on the caller by saying that patches containing |
Copy is also a problem. First, an important invariant is that The obvious inverse of One suggestion by @unscriptable is to augment patch operations with an optional { op: 'remove', from: '/todos/2', inverse: { op: 'copy', from: '/todos/1', path: '/todos/2 }' } Where the |
In the near term, here's what I'm gonna do:
|
This sounds like a great idea! |
Cool, thanks @aaronshaf. I've implemented a proof-of-concept of the inverse strategy above, and so far it's working well. I need to write more tests for it, but I'm hoping to have it committed tomorrow. |
Initial version of patch inversion in #14. |
Patch inverses landed in #14. We may find out that we have to amend the format for other types of inverses (or even just for |
Being able to invert patches can help in patch commutation and other scenarios. We should at least consider adding it.
The text was updated successfully, but these errors were encountered: