Skip to content

make patch works wrong for lists #4

Closed
@kxepal

Description

@kxepal

In short, there is very simple case that fails:

from jsonpatch import apply_patch, make_patch
src = {'foo': [1, 3]}
dst = {'foo': [0, 3, 3, 2]}
print apply_patch(src, make_patch(src, dst))

That's possible because of reversed statement at https://github.com/stefankoegl/python-json-patch/blob/master/jsonpatch.py#L244
If we remove it code above would work perfectly, but we'll break next case:

from jsonpatch import apply_patch, make_patch
src = {'foo': [1, 3]}
dst = {'foo': [0, 3, 3, 2]}
print apply_patch(dst, make_patch(dst, src))

In other words, we have to add items in ascending order and remove them in descending one. That's my code and my fault, I'll try to figure how to fix it in better way, just creating issue there to let you know about problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions