Parse-SDK-JS icon indicating copy to clipboard operation
Parse-SDK-JS copied to clipboard

fix: toJSON() repeats pending updates to nested keys

Open mstniy opened this issue 3 years ago • 2 comments

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)

mstniy avatar Feb 16 '22 10:02 mstniy

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: #123 in 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>.

mtrezza avatar Feb 16 '22 22:02 mtrezza

@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 avatar May 02 '24 15:05 dplewis

@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 avatar May 02 '24 15:05 mstniy

@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();
  });

dplewis avatar May 02 '24 20:05 dplewis

I will reformat the title to use the proper commit message syntax.

@dplewis Added the test with small modifications

mstniy avatar May 02 '24 21:05 mstniy

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.

codecov[bot] avatar May 02 '24 21:05 codecov[bot]

🎉 This change has been released in version 5.1.0-alpha.8

parseplatformorg avatar May 02 '24 23:05 parseplatformorg

🎉 This change has been released in version 5.1.0-beta.1

parseplatformorg avatar May 16 '24 12:05 parseplatformorg

🎉 This change has been released in version 5.1.0

parseplatformorg avatar May 16 '24 13:05 parseplatformorg