Closed rkusa closed 10 years ago
Definitely the latter. Each operation should be fully applied before the next starts. I'm pretty sure that's how all existing implementations will do it. Definitely agree that a test should be put in to make sure though.
Thanks for the answer @almost! I also found the relevant part in the spec.
Operations are applied sequentially in the order they appear in the array. Each operation in the sequence is applied to the target document; the resulting document becomes the target of the next operation. Evaluation continues until all operations are successfully applied or until an error condition is encountered.
So as you said, the latter is correct. Thanks
Can't hurt! One could imagine someone trying to collapse multiple patches and going astray. Also, this tripped up my implementation's diff(), so... good test! (My implementation mines these testcases to make diffs and reverse diffs between 'doc' and 'expected.).
I was just wondering what to expect from a patch containing multiple
remove
operations to the same array, e.g.:Object:
{ "arr": [1, 2, 3, 4] }
Patch:
Should the result be
{ "arr": [1, 4] }
or{ "arr": [1, 3] }
. Or in words: should every remove operation be applied before shifting existing elements to the left, or should existing elements be shifted to the left after eachremove
operation?This case is maybe worth adding a test for.