parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Pass deeply nested keys correctly to afterSave triggers

Open mstniy opened this issue 4 years ago • 15 comments
trafficstars

New Pull Request Checklist

  • [x] I am not disclosing a vulnerability.
  • [x] I am creating this PR in reference to an issue.

Issue Description

Related issue: #7384

Approach

RestWrite.buildUpdatedObject now functions correctly even for deeply nested keys.

TODOs before merging

  • [x] Add test cases
  • [x] Add entry to changelog
  • [ ] Add changes to documentation (guides, repository pages, in-code descriptions)
  • [ ] Add security check
  • [ ] Add new Parse Error codes to Parse JS SDK
  • [ ] ...

mstniy avatar May 12 '21 13:05 mstniy

Codecov Report

Merging #7385 (85a9a94) into master (bdf73a0) will decrease coverage by 9.29%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7385      +/-   ##
==========================================
- Coverage   93.92%   84.62%   -9.30%     
==========================================
  Files         181      181              
  Lines       13209    13201       -8     
==========================================
- Hits        12406    11172    -1234     
- Misses        803     2029    +1226     
Impacted Files Coverage Δ
src/RestWrite.js 93.85% <100.00%> (-0.08%) :arrow_down:
...dapters/Storage/Postgres/PostgresStorageAdapter.js 2.47% <0.00%> (-92.90%) :arrow_down:
src/Adapters/Storage/Postgres/PostgresClient.js 5.00% <0.00%> (-65.00%) :arrow_down:
src/Controllers/UserController.js 95.34% <0.00%> (-2.33%) :arrow_down:
src/Controllers/FilesController.js 92.00% <0.00%> (-2.00%) :arrow_down:
src/Controllers/index.js 96.66% <0.00%> (-1.12%) :arrow_down:
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 92.59% <0.00%> (-0.66%) :arrow_down:
src/Routers/UsersRouter.js 93.16% <0.00%> (-0.63%) :arrow_down:
src/middlewares.js 96.71% <0.00%> (-0.47%) :arrow_down:
src/Controllers/SchemaController.js 97.16% <0.00%> (-0.19%) :arrow_down:
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update bdf73a0...85a9a94. Read the comment docs.

codecov[bot] avatar May 12 '21 13:05 codecov[bot]

@mstniy Can you add this fix to the ChangeLog?

dplewis avatar May 12 '21 17:05 dplewis

This looks suspicious.

This PR removes lot of code from RestWrite and replaces it with a line that was already within the removed code.

Did you research why the logic around the line that you intend to keep was there previously? Is it possible that the logic was there to accommodate certain use cases?

mtrezza avatar May 12 '21 17:05 mtrezza

@mtrezza ParseObject.set is capable of handling nested keys, no matter the depth. The regression tests actually makes use of this capability. I am not sure why the previous snippet did the split manually. Perhaps it was written before ParseObject.set gained that ability, or the contributor wasn't aware it could do that? But that's pure speculation.

Thus, the else branch also becomes a simple call to ParseObject.set, so I have removed the branch entirely. I am not sure why the code checks for a dot, so I have left that part intact.

mstniy avatar May 12 '21 18:05 mstniy

@mstniy Can you add this fix to the ChangeLog?

Done

mstniy avatar May 12 '21 18:05 mstniy

@mstniy @mtrezza Support for nested objects was recently improved in the SDK https://github.com/parse-community/Parse-SDK-JS/releases/tag/3.1.0

That’s the reason why this cleanup works so well.

dplewis avatar May 12 '21 18:05 dplewis

Aha, that may explain it indeed, thanks.

mtrezza avatar May 12 '21 19:05 mtrezza

Blocked on parse-community/Parse-SDK-JS#1364

mstniy avatar May 13 '21 19:05 mstniy

⚠️ Important change for merging PRs from Parse Server 5.0 onwards!

We are planning to release the first beta version of Parse Server 5.0 in October 2021.

If a PR contains a breaking change and is not merged before the beta release of Parse Server 5.0, it cannot be merged until the end of 2022. Instead it has to follow the Deprecation Policy and phase-in breaking changes to be merged during the course of 2022.

One of the most voiced community feedbacks was the demand for predictability in breaking changes to make it easy to upgrade Parse Server. We have made a first step towards this by introducing the Deprecation Policy in February 2021 that assists to phase-in breaking changes, giving developers time to adapt. We will follow-up with the introduction of Release Automation and a branch model that will allow breaking changes only with a new major release, scheduled for the beginning of each calendar year.

We understand that some PRs are a long time in the making and we very much appreciate your contribution. We want to make it easy for PRs that contain a breaking change and were created before the introduction of the Deprecation Policy. These PRs can be merged with a breaking change without being phased-in before the beta release of Parse Server 5.0. We are making this exception because we appreciate that this is a time of transition that requires additional effort from contributors to adapt. We encourage everyone to prepare their PRs until the end of September and account for review time and possible adaptions.

If a PR contains a breaking change and should be merged before the beta release, please mention @parse-community/server-maintenance and we will coordinate with you to merge the PR.

Thanks for your contribution and support during this transition to Parse Server release automation!

mtrezza avatar Sep 03 '21 00:09 mtrezza

Hey, just found that this issue still persist with [email protected] and [email protected]. If the pr looks good, can someone merge and release it? Thanks !

RahulLanjewar93 avatar Apr 16 '25 12:04 RahulLanjewar93

@RahulLanjewar93 I thought @mstniy fixed this on the JavaScript client side. Can you open a new issue?

Edit: Oh I see what they did, I basically copied the dot notation JS code to the server before they improved it

dplewis avatar Apr 16 '25 12:04 dplewis

@RahulLanjewar93 I thought @mstniy fixed this on the JavaScript client side. Can you open a new issue?

Edit: Oh I see what they did, I basically copied the dot notation JS code to the server before they improved it

I think we still need this pr to be merged so that it uses the default set behaviour from parse js sdk?

RahulLanjewar93 avatar Apr 16 '25 12:04 RahulLanjewar93

@RahulLanjewar93 Can you copy the code and open a new PR? This one is on draft mode

dplewis avatar Apr 16 '25 13:04 dplewis

@RahulLanjewar93 Can you copy the code and open a new PR? This one is on draft mode

Sure

RahulLanjewar93 avatar Apr 16 '25 13:04 RahulLanjewar93

@dplewis created a new pr here by copying the changes. Should it be pointed to alpha or release-7.x.x? #9720

RahulLanjewar93 avatar Apr 16 '25 13:04 RahulLanjewar93