fix(documentResource): send only changed fields on save#803
Open
ps173 wants to merge 2 commits into
Open
Conversation
save serialized the whole doc and stripped only doctype and name, so standard fields like owner, creation, modified, docstatus and idx leaked into the set_value payload and the server rejected it with "Cannot edit standard fields". Diff against originalDoc and send only changed fields. Fixes frappe#802 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
/barista review |
|
Looks good — diffs Minor nit:
|
Short-circuit save when the diff is empty so it no longer fires a set_value request with an empty fieldname. Diff logic extracted into a shared getChangedFields helper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Addressed the review nit in 367b3e9
All 174 tests pass |
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.
Problem
save.makeParamsserialized the entire doc and stripped onlydoctypeandname, so read only standard fields returned byfrappe.client.get(owner,creation,modified,modified_by,docstatus,idx) leaked into theset_valuepayload. The server rejected it withCannot edit standard fieldsand the edit was never persisted.Fix
Diff
out.docagainstout.originalDocand send only the changed fields. SinceoriginalDocis a snapshot taken right after load, unchanged standard fields never enter the payload.doctypeandnameare still stripped to cover the case whereoriginalDocis null.Tests
Added
src/resources/documentResource.test.tscovering changed field only payloads, the no change case and the multi field subset case.Fixes #802
🤖 Generated with Claude Code
Coverage: 58.03% (+0.05% vs
main)