fix: Fixed issue where deeply nested keys were having incorrect values
refer https://github.com/parse-community/parse-server/pull/7385#issuecomment-2809633747
Summary by CodeRabbit
-
Bug Fixes
- Improved handling of keys with dot notation, ensuring nested fields are updated correctly during save operations.
-
Tests
- Added a new test to verify correct behavior when saving objects with deeply nested keys, specifically validating afterSave triggers and nested field updates.
I will reformat the title to use the proper commit message syntax.
π Thanks for opening this pull request!
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 93.00%. Comparing base (
0db3a6f) to head (7cf54f0). Report is 1 commits behind head on alpha.
Additional details and impacted files
@@ Coverage Diff @@
## alpha #9720 +/- ##
=======================================
Coverage 93.00% 93.00%
=======================================
Files 187 187
Lines 15082 15073 -9
Branches 174 174
=======================================
- Hits 14027 14019 -8
+ Misses 1043 1042 -1
Partials 12 12
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Looks like itβs failing in Postgres, getting recursive coalesces (dot notation) working would be a challenge
Looks like itβs failing in Postgres, getting recursive coalesces (dot notation) working would be a challenge
I'll try to work on this part, do you have any insights on where to look into? I'm not a Postgres expert
Here you go, it might work I'll try as well, might be a week
https://github.com/parse-community/parse-server/blob/ed69e03acf091824adadcc8297eec0c47ff05322/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js#L185-L187
@RahulLanjewar93 We can make this test Mongo only as PG Dot notation support is limited already.
@RahulLanjewar93 We can make this test Mongo only as PG Dot notation support is limited already.
Ok I'll make changes accordingly then
I will reformat the title to use the proper commit message syntax.
π Walkthrough
Walkthrough
The changes simplify the handling of keys containing dots in the buildParseObjects method of RestWrite.js, removing special logic for operation and subdocument keys. Now, all dotted keys are set directly on the updated object without distinction. Additionally, a new test case is added to spec/ParseObject.spec.js to verify correct behavior when saving objects with deeply nested keys, ensuring that afterSave triggers receive the expected nested field values after various modifications.
Changes
| File(s) | Change Summary |
|---|---|
| src/RestWrite.js | Simplified handling of keys with dots in buildParseObjects by removing special-case logic for operation/subdoc keys; now all dotted keys are set directly on the updated object. |
| spec/ParseObject.spec.js | Added a MongoDB-specific test verifying correct afterSave behavior for deeply nested keys through a sequence of saves and modifications. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant Server
participant afterSaveTrigger
Client->>Server: Save GameScore object with nested keys
Server->>afterSaveTrigger: Invoke afterSave with saved object
afterSaveTrigger->>Server: Validate nested keys, increment counter
Server-->>Client: Respond to save request
Note over Server,afterSaveTrigger: This sequence repeats for each save with modifications to nested keys.
π Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro
π₯ Commits
Reviewing files that changed from the base of the PR and between 6bb09ffc6edbcf5d1c51c4a31e6f2ccec0c5158f and 7d60238b4077137de36e79c4c7b68c87cbbbfb3a.
π Files selected for processing (1)
spec/ParseObject.spec.js(1 hunks)
π§° Additional context used
𧬠Code Graph Analysis (1)
spec/ParseObject.spec.js (3)
spec/ParseAPI.spec.js (8)
Parse(6-6)object(673-673)object(719-719)obj(38-38)obj(319-319)obj(413-413)obj(691-691)obj(747-747)spec/helper.js (1)
Parse(4-4)spec/CloudCode.spec.js (11)
Parse(3-3)obj(142-142)obj(191-191)obj(210-210)obj(238-238)obj(258-258)obj(305-305)obj(584-584)obj(589-589)obj(610-610)obj(623-623)
πͺ ESLint
spec/ParseObject.spec.js
[error] 2175-2175: 'it_only_db' is not defined.
(no-undef)
[error] 2179-2179: 'expect' is not defined.
(no-undef)
[error] 2183-2183: 'expect' is not defined.
(no-undef)
[error] 2184-2184: 'expect' is not defined.
(no-undef)
[error] 2187-2187: 'expect' is not defined.
(no-undef)
[error] 2188-2188: 'expect' is not defined.
(no-undef)
[error] 2191-2191: 'expect' is not defined.
(no-undef)
[error] 2192-2192: 'expect' is not defined.
(no-undef)
[error] 2195-2195: 'expect' is not defined.
(no-undef)
[error] 2196-2196: 'expect' is not defined.
(no-undef)
[error] 2199-2199: 'expect' is not defined.
(no-undef)
[error] 2200-2200: 'expect' is not defined.
(no-undef)
[error] 2224-2224: 'expect' is not defined.
(no-undef)
β° Context from checks skipped due to timeout of 90000ms (12)
- GitHub Check: PostgreSQL 15, PostGIS 3.5
- GitHub Check: PostgreSQL 15, PostGIS 3.3
- GitHub Check: PostgreSQL 16, PostGIS 3.5
- GitHub Check: PostgreSQL 17, PostGIS 3.5
- GitHub Check: PostgreSQL 15, PostGIS 3.4
- GitHub Check: Redis Cache
- GitHub Check: Node 20
- GitHub Check: MongoDB 7, ReplicaSet
- GitHub Check: Node 18
- GitHub Check: MongoDB 8, ReplicaSet
- GitHub Check: Docker Build
- GitHub Check: MongoDB 6, ReplicaSet
π Additional comments (1)
spec/ParseObject.spec.js (1)
2175-2225: Well implemented test case for the bug fix.This new MongoDB-specific test thoroughly verifies the fix for the issue with deeply nested keys by testing various scenarios:
- Creating an object with nested fields
- Incrementing values in nested fields
- Setting new values in nested fields
- Unsetting deeply nested fields
- Unsetting intermediate nested fields
The test correctly ensures the afterSave trigger receives the expected values after each operation. Making this test MongoDB-specific aligns with the PR objectives, where it was mentioned that Postgres has limited support for dot notation.
π§° Tools
πͺ ESLint
[error] 2175-2175: 'it_only_db' is not defined.
(no-undef)
[error] 2179-2179: 'expect' is not defined.
(no-undef)
[error] 2183-2183: 'expect' is not defined.
(no-undef)
[error] 2184-2184: 'expect' is not defined.
(no-undef)
[error] 2187-2187: 'expect' is not defined.
(no-undef)
[error] 2188-2188: 'expect' is not defined.
(no-undef)
[error] 2191-2191: 'expect' is not defined.
(no-undef)
[error] 2192-2192: 'expect' is not defined.
(no-undef)
[error] 2195-2195: 'expect' is not defined.
(no-undef)
[error] 2196-2196: 'expect' is not defined.
(no-undef)
[error] 2199-2199: 'expect' is not defined.
(no-undef)
[error] 2200-2200: 'expect' is not defined.
(no-undef)
[error] 2224-2224: 'expect' is not defined.
(no-undef)
πͺ§ Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
What's the state of this PR?
:tada: Snyk checks have passed. No issues have been found so far.
:white_check_mark: security/snyk check is complete. No issues have been found. (View Details)
What's the state of this PR?
I have to change the test to mongo instead of generic test. Have been occupied with something will do it sometime this week
What's the state of this PR?
Ready for review/merging