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

feat: Support dot notation on array fields

Open dplewis opened this issue 1 year ago • 3 comments

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: https://github.com/parse-community/parse-server/issues/6687

Approach

Check types for Array vs Fields based on dot notation format.

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

Tasks

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

dplewis avatar May 02 '24 15:05 dplewis

Thanks for opening this pull request!

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

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

dplewis avatar May 05 '24 00:05 dplewis

@mtrezza This is ready for review.

dplewis avatar Jul 07 '24 01:07 dplewis

Looks good to me, also the tests seem to cover it well; and with the additional test from https://github.com/parse-community/parse-server/issues/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.

mtrezza avatar Jul 07 '24 22:07 mtrezza

We are good to merge after the tests pass.

dplewis avatar Jul 07 '24 23:07 dplewis

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

mtrezza avatar Jul 08 '24 20:07 mtrezza

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.

dplewis avatar Jul 08 '24 20:07 dplewis

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

parseplatformorg avatar Jul 08 '24 21:07 parseplatformorg

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

parseplatformorg avatar Jul 09 '24 00:07 parseplatformorg

🎉 This change has been released in version 7.2.0

parseplatformorg avatar Jul 09 '24 01:07 parseplatformorg

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

dplewis avatar Jul 09 '24 02:07 dplewis