Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for dot notation on array fields of Parse Object #9115

Merged
merged 12 commits into from
Jul 8, 2024

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented May 2, 2024

Pull Request

Issue

Currently all dot notations are treated as operations on Object type field. This results in a error: Cannot read property '0' of undefined when used on Array type fields.

Closes: #6687

Approach

  • Check types for Array vs Fields based on dot notation format.
  • If dot notation is used prevent array to object conversion

https://www.mongodb.com/docs/manual/core/document/#dot-notation

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK

Copy link

Thanks for opening this pull request!

@dplewis dplewis requested a review from a team May 2, 2024 16:16
Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.14%. Comparing base (892052c) to head (fffc003).

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #9115      +/-   ##
==========================================
- Coverage   94.15%   94.14%   -0.01%     
==========================================
  Files         186      186              
  Lines       14738    14750      +12     
==========================================
+ Hits        13877    13887      +10     
- Misses        861      863       +2     

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

@mtrezza mtrezza changed the title feat: Support dot notation on Array fields feat: Support dot notation on array fields May 3, 2024
mtrezza
mtrezza previously approved these changes May 3, 2024
@dplewis
Copy link
Member Author

dplewis commented May 5, 2024

@mtrezza This is an extremely complicated feature. I tried running this with the SDK internal fix against the server test suite and got Array dot notation working but it somehow broke the server. I’ll let you know when this is ready for review.

@mtrezza mtrezza marked this pull request as draft May 6, 2024 00:32
@dplewis dplewis marked this pull request as ready for review July 7, 2024 01:27
@dplewis
Copy link
Member Author

dplewis commented Jul 7, 2024

@mtrezza This is ready for review.

@dplewis dplewis requested review from mtrezza and a team July 7, 2024 01:30
mtrezza
mtrezza previously approved these changes Jul 7, 2024
@mtrezza
Copy link
Member

mtrezza commented Jul 7, 2024

Looks good to me, also the tests seem to cover it well; and with the additional test from #9179 I think we are on the safe side. Good to merge? I would then make a Parse Server stable release and deprecate Parse Server 7.1.0 due to the JS SDK bug.

@dplewis
Copy link
Member Author

dplewis commented Jul 7, 2024

We are good to merge after the tests pass.

@mtrezza
Copy link
Member

mtrezza commented Jul 8, 2024

Tests pass; but I see you made more commits; should I go ahead and merge?

@dplewis
Copy link
Member Author

dplewis commented Jul 8, 2024

This is good to merge. I'll improve Postgres support in another PR (e.g increment, add, remove, delete). This PR has query support for PG so its a good start.

@mtrezza mtrezza changed the title feat: Support dot notation on array fields feat: Add support for dot notation on array fields Jul 8, 2024
@mtrezza mtrezza changed the title feat: Add support for dot notation on array fields feat: Add support for dot notation on Parse Object array fields Jul 8, 2024
@mtrezza mtrezza changed the title feat: Add support for dot notation on Parse Object array fields feat: Add support for dot notation on array fields of Parse Object Jul 8, 2024
@mtrezza mtrezza merged commit cf4c880 into parse-community:alpha Jul 8, 2024
25 of 26 checks passed
parseplatformorg pushed a commit that referenced this pull request Jul 8, 2024
# [7.1.0-alpha.16](7.1.0-alpha.15...7.1.0-alpha.16) (2024-07-08)

### Features

* Add support for dot notation on array fields of Parse Object ([#9115](#9115)) ([cf4c880](cf4c880))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.1.0-alpha.16

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jul 8, 2024
@dplewis dplewis deleted the dot-notation-array branch July 9, 2024 00:12
parseplatformorg pushed a commit that referenced this pull request Jul 9, 2024
# [7.2.0-beta.1](7.1.0...7.2.0-beta.1) (2024-07-09)

### Bug Fixes

* Invalid push notification tokens are not cleaned up from database for FCM API v2 ([#9173](#9173)) ([284da09](284da09))

### Features

* Add support for dot notation on array fields of Parse Object ([#9115](#9115)) ([cf4c880](cf4c880))
* Upgrade to @parse/push-adapter 6.4.0 ([#9182](#9182)) ([ef1634b](ef1634b))
* Upgrade to Parse JS SDK 5.3.0 ([#9180](#9180)) ([dca187f](dca187f))
@parseplatformorg
Copy link
Contributor

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

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Jul 9, 2024
parseplatformorg pushed a commit that referenced this pull request Jul 9, 2024
# [7.2.0](7.1.0...7.2.0) (2024-07-09)

### Bug Fixes

* Invalid push notification tokens are not cleaned up from database for FCM API v2 ([#9173](#9173)) ([284da09](284da09))

### Features

* Add support for dot notation on array fields of Parse Object ([#9115](#9115)) ([cf4c880](cf4c880))
* Upgrade to @parse/push-adapter 6.4.0 ([#9182](#9182)) ([ef1634b](ef1634b))
* Upgrade to Parse JS SDK 5.3.0 ([#9180](#9180)) ([dca187f](dca187f))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.2.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Jul 9, 2024
@dplewis
Copy link
Member Author

dplewis commented Jul 9, 2024

Just FYI,

Array operations like increment, add, remove currently doesn't work with dot notation because PG doesn't support multidimensional arrays and for one dimensional arrays you don't need dot notation. A lot of COALESE for missing indexes and custom .sql script would be needed but it is doable probably.

I created a branch incase anybody isn interested. Currently for arrays you can fetch, update and save but it won't be atomic.

https://github.com/parse-community/parse-server/compare/alpha...dplewis:parse-server:dot-notation-ops?expand=1

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.

How to increment array nested object field?
3 participants