Skip to content

Conversation

mstniy
Copy link
Contributor

@mstniy mstniy commented Feb 16, 2022

New Pull Request Checklist

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

  • Add tests
  • Add entry to changelog
  • Add changes to documentation (guides, repository pages, in-code descriptions)

@parse-github-assistant
Copy link

parse-github-assistant bot commented Feb 16, 2022

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.

@mtrezza
Copy link
Member

mtrezza commented Feb 16, 2022

To fix the commit message check, could you please change the title to fix: <summary of bug>.

@mstniy mstniy changed the title Fix #1452 fix: toJSON() repeats pending updates to nested keys Feb 16, 2022
@dplewis
Copy link
Member

dplewis commented May 2, 2024

@mstniy @mtrezza I think #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.

@mstniy
Copy link
Contributor Author

mstniy commented May 2, 2024

@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?

@dplewis
Copy link
Member

dplewis commented May 2, 2024

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

@mstniy mstniy force-pushed the nested_tojson_1452 branch from ec75ddb to 21bcaae Compare May 2, 2024 21:09
Copy link

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

@parse-github-assistant parse-github-assistant bot changed the title fix: toJSON() repeats pending updates to nested keys fix: ToJSON() repeats pending updates to nested keys May 2, 2024
@mstniy
Copy link
Contributor Author

mstniy commented May 2, 2024

@dplewis Added the test with small modifications

Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dplewis dplewis requested a review from a team May 2, 2024 21:54
Copy link
Member

@dplewis dplewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mtrezza mtrezza changed the title fix: ToJSON() repeats pending updates to nested keys fix: Pending updates to nested fields cause ParseObject.toJSON() to return incorrect object May 2, 2024
@mtrezza mtrezza changed the title fix: Pending updates to nested fields cause ParseObject.toJSON() to return incorrect object fix: Pending updates to nested field causes ParseObject.toJSON() to return incorrect object May 2, 2024
@mtrezza mtrezza merged commit 23cc573 into parse-community:alpha May 2, 2024
parseplatformorg pushed a commit that referenced this pull request May 2, 2024
# [5.1.0-alpha.8](5.1.0-alpha.7...5.1.0-alpha.8) (2024-05-02)

### Bug Fixes

* Pending updates to nested field causes `ParseObject.toJSON()` to return incorrect object ([#1453](#1453)) ([23cc573](23cc573))
@parseplatformorg
Copy link
Contributor

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

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label May 2, 2024
@mstniy mstniy deleted the nested_tojson_1452 branch May 2, 2024 23:18
parseplatformorg pushed a commit that referenced this pull request May 16, 2024
# [5.1.0-beta.1](5.0.0...5.1.0-beta.1) (2024-05-16)

### Bug Fixes

* `Parse.GeoPoint.current` returns `undefined` ([#2127](#2127)) ([3860535](3860535))
* Chrome browser console warning about unsafe header `access-control-expose-headers` when calling Cloud Function ([#2095](#2095)) ([7b73c03](7b73c03))
* Live Query not working on Expo React Native ([#2109](#2109)) ([7a89665](7a89665))
* Local datastore throws error when `Parse.Query.notEqualTo` is set to `null` ([#2102](#2102)) ([6afd32a](6afd32a))
* Multiple object updates of nested keys overwrite each other ([#1451](#1451)) ([fa4341a](fa4341a))
* Pending updates to nested field causes `ParseObject.toJSON()` to return incorrect object ([#1453](#1453)) ([23cc573](23cc573))
* Remove circular dependencies ([#2125](#2125)) ([b415165](b415165))

### Features

* Add password validation for user with unverified email via `Parse.User.verifyPassword` using master key and option `ignoreEmailVerification: true` ([#2076](#2076)) ([b0adf7e](b0adf7e))
* Add support for setting `Parse.ACL` from json ([#2097](#2097)) ([72bc9ac](72bc9ac))
* Allow setting custom queue for handling offline operations via `Parse.EventuallyQueue` ([#2106](#2106)) ([f92e4d4](f92e4d4))
* Improve installation object `Parse.Installation.currentInstallation` to support web push notifications ([#2119](#2119)) ([4fc62ce](4fc62ce))
* Lazy load `Parse.CoreManager` controllers to add support for swappable `CryptoController`, `LocalDatastoreController`, `StorageController`, `WebSocketController`, `ParseLiveQuery` ([#2100](#2100)) ([fbd0ab1](fbd0ab1))
@parseplatformorg
Copy link
Contributor

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

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label May 16, 2024
parseplatformorg pushed a commit that referenced this pull request May 16, 2024
# [5.1.0](5.0.0...5.1.0) (2024-05-16)

### Bug Fixes

* `Parse.GeoPoint.current` returns `undefined` ([#2127](#2127)) ([3860535](3860535))
* Chrome browser console warning about unsafe header `access-control-expose-headers` when calling Cloud Function ([#2095](#2095)) ([7b73c03](7b73c03))
* Live Query not working on Expo React Native ([#2109](#2109)) ([7a89665](7a89665))
* Local datastore throws error when `Parse.Query.notEqualTo` is set to `null` ([#2102](#2102)) ([6afd32a](6afd32a))
* Multiple object updates of nested keys overwrite each other ([#1451](#1451)) ([fa4341a](fa4341a))
* Pending updates to nested field causes `ParseObject.toJSON()` to return incorrect object ([#1453](#1453)) ([23cc573](23cc573))
* Remove circular dependencies ([#2125](#2125)) ([b415165](b415165))

### Features

* Add password validation for user with unverified email via `Parse.User.verifyPassword` using master key and option `ignoreEmailVerification: true` ([#2076](#2076)) ([b0adf7e](b0adf7e))
* Add support for setting `Parse.ACL` from json ([#2097](#2097)) ([72bc9ac](72bc9ac))
* Allow setting custom queue for handling offline operations via `Parse.EventuallyQueue` ([#2106](#2106)) ([f92e4d4](f92e4d4))
* Improve installation object `Parse.Installation.currentInstallation` to support web push notifications ([#2119](#2119)) ([4fc62ce](4fc62ce))
* Lazy load `Parse.CoreManager` controllers to add support for swappable `CryptoController`, `LocalDatastoreController`, `StorageController`, `WebSocketController`, `ParseLiveQuery` ([#2100](#2100)) ([fbd0ab1](fbd0ab1))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.1.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toJSON() repeats pending updates to nested keys
4 participants