Repository navigation
Support whole document operations on scalar documents (#213) - #219
Open
stefankoegl wants to merge 2 commits into
Open
stefankoegl wants to merge 2 commits into
stefankoegl wants to merge 2 commits into
Conversation
A JSON document can be a scalar, but operations on the whole document (path "") raised a bare TypeError for one, which is not part of the documented exceptions: - 'add' (and 'copy', which goes through it) to "" now replaces the document whatever its type, as 'replace' already did. - 'remove' of "" now raises JsonPatchConflict for every type of document, instead of a TypeError for scalars and a misleading "non-existent object 'None'" / "invalid array index 'None'" for objects and arrays. - 'move' from "" resolves the whole document as 'copy' does, so moving it onto itself is a no-op and moving it elsewhere fails with JsonPatchConflict. This also removes the TypeError for array documents from #214; its check for moves into a location's own children is still missing. The TypeError branches in 'replace' could no longer be reached and are removed. test_whole_document_as_target now holds; test_raises_only_documented_exceptions still fails, only because of #215. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01964EYaTCKUya9tcPjhytDq
master now rejects moves into a location's own children (#214), which also covers 'move' from "". Resolved by keeping master's MoveOperation: it returns early when 'from' is "", so the whole-document branch this branch had added there is dropped as unreachable. The comment on the 'move' from "" example keeps master's reference to #214. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01964EYaTCKUya9tcPjhytDq
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A JSON document can be a scalar, but operations on the whole document
(path "") raised a bare TypeError for one, which is not part of the
documented exceptions:
document whatever its type, as 'replace' already did.
instead of a TypeError for scalars and a misleading "non-existent
object 'None'" / "invalid array index 'None'" for objects and arrays.
it onto itself is a no-op and moving it elsewhere fails with
JsonPatchConflict. This also removes the TypeError for array documents
from move does not reject moving an array element into its own children, and crashes when moving the whole array #214; its check for moves into a location's own children is
still missing.
The TypeError branches in 'replace' could no longer be reached and are
removed. test_whole_document_as_target now holds;
test_raises_only_documented_exceptions still fails, only because of #215.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01964EYaTCKUya9tcPjhytDq