Make `move` operation with from == path a no-op

This commit is contained in:
Stefan Kögl
2016-02-13 15:41:18 +01:00
parent a33021bf5a
commit 4443d3241b

View File

@@ -484,6 +484,10 @@ class MoveOperation(PatchOperation):
except (KeyError, IndexError) as ex:
raise JsonPatchConflict(str(ex))
# If source and target are equal, this is a no-op
if self.pointer == from_ptr:
return obj
if isinstance(subobj, MutableMapping) and \
self.pointer.contains(from_ptr):
raise JsonPatchConflict('Cannot move values into its own children')