-
Notifications
You must be signed in to change notification settings - Fork 219
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
validate corrupts patches when adding array then appending #76
Comments
This also works with objects:
Output:
Looks like patch value gets copied by reference instead of deep copy. |
How does this work with undefined values? IIRC, this repo tries to respect On Tue, May 3, 2016, 9:53 AM baranga notifications@github.com wrote:
|
@MarkHerhold I don't understand your question. How to deep copy something with a |
@baranga You are right, it shouldn't happen in the traditional JSON sense, but JSON-Patch treats Here's an example: > var jsonpatch = require('fast-json-patch')
undefined
> var obj = {};
undefined
> jsonpatch.apply(obj, [{op: 'add', path:"/thing", value: undefined}]);
true
> Object.keys(obj)
[ 'thing' ]
> obj.thing
undefined |
@MarkHerhold That still works. Is that behaviour covered by the test suites? I run them with my modifications and got same errors as on master. |
Ok, now I see the issue: > var jsonpatch = require('./src/json-patch-duplex')
undefined
> var obj = {}
undefined
> jsonpatch.apply(obj, [{op: 'add', path: '/deepThing', value: {undef: undefined}}])
true
> Object.keys(obj)
[ 'deepThing' ]
> Object.keys(obj.deepThing)
[] But the last should be: > Object.keys(obj.deepThing)
[ 'undef' ] |
@MarkHerhold So right now something broken can't be fixed because the lib supports a non standard feature? |
No, there are other more expensive clone strategies and implementations. I personally think we should cut a v1 release, dropping support for On Wed, May 4, 2016, 3:19 AM baranga notifications@github.com wrote:
|
The part regarding |
Hello,
You can try the following code:
It outputs:
As you can see the value object of the first patch has been modified. Instead of an empty array it is now an array containing the value of the second patch.
The text was updated successfully, but these errors were encountered: