Parse-SDK-JS
Parse-SDK-JS copied to clipboard
fix: toJSON() repeats pending updates to nested keys
New Pull Request Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am creating this PR in reference to an issue.
Issue Description
Fix #1452
Related issue: #1452
Approach
ParseObject.toJSON() no longer applies pending operations a second time. attributes takes care of them already.
TODOs before merging
- [x] Add tests
- [x] Add entry to changelog
- [ ] Add changes to documentation (guides, repository pages, in-code descriptions)
Thanks for opening this pull request!
- ❌ Please link an issue that describes the reason for this pull request, otherwise your pull request will be closed. Make sure to write it as
Closes: #123in the PR description, so I can recognize it.
To fix the commit message check, could you please change the title to fix: <summary of bug>.
@mstniy @mtrezza I think https://github.com/parse-community/Parse-SDK-JS/pull/1451 also fixes this issue. Can you have a look? I can't seem to get duplicate pending operations to appear with this new fix in place.
@dplewis Strange that you cannot replicate it. I tested it with #1451 and the issue was still there.
Did you follow the steps in #1452?
@mstniy Ok this looks good. Can you add the following integration test?
it('can set nested fields without repeating pending operations on toJSON', async () => {
const a = new Parse.Object("MyObject");
a.set('obj', {});
await a.save();
a.set('obj.a', 0);
const json = a.toJSON();
expect(json.obj).toEqual({ a: 0 });
expect(json['obj.a']).toBeUndefined();
});
I will reformat the title to use the proper commit message syntax.
@dplewis Added the test with small modifications
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
72bc9ac) to head (21bcaae). Report is 17 commits behind head on alpha.
Additional details and impacted files
@@ Coverage Diff @@
## alpha #1453 +/- ##
===========================================
+ Coverage 99.98% 100.00% +0.01%
===========================================
Files 61 64 +3
Lines 6185 6205 +20
Branches 1499 1504 +5
===========================================
+ Hits 6184 6205 +21
+ Misses 1 0 -1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
🎉 This change has been released in version 5.1.0-alpha.8
🎉 This change has been released in version 5.1.0-beta.1
🎉 This change has been released in version 5.1.0