You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered unexpected behavior when running the example in the docs here. After applying, the patch itself has changed. I expected it to be immutable so I could re-use the patch object, but this is not the case.
If a patch is only used once, it is not necessary to create a patch object explicitly.
which implies that a jsonpatch.JsonPatch object can be used more than once. However, it appears that a patch is potentially single-use, depending on whether it includes mutable values (lists/dicts).
I think this can be resolved by doing a deepcopy when initializing the operation attribute in the PatchOperation class.
The text was updated successfully, but these errors were encountered:
I fully agree that the patch object should be immutable. Instead of deepcopying I'd be in favor of changing apply so that it does not modify its state.
Would you be able to work on a pull request for such a change?
I encountered unexpected behavior when running the example in the docs here. After applying, the patch itself has changed. I expected it to be immutable so I could re-use the patch object, but this is not the case.
Example:
Note that the second operation is now different from what it was originally.
In the docs here, it says
which implies that a
jsonpatch.JsonPatch
object can be used more than once. However, it appears that a patch is potentially single-use, depending on whether it includes mutable values (lists/dicts).I think this can be resolved by doing a deepcopy when initializing the
operation
attribute in thePatchOperation
class.The text was updated successfully, but these errors were encountered: