-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Don't error when attempting to sort on an object field #4806
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
Don't error when attempting to sort on an object field #4806
Conversation
well postgress doesn't like it. |
@vitaly-t any feedback on the postgress failure? |
Codecov Report
@@ Coverage Diff @@
## master #4806 +/- ##
==========================================
- Coverage 92.69% 92.69% -0.01%
==========================================
Files 119 119
Lines 8684 8688 +4
==========================================
+ Hits 8050 8053 +3
- Misses 634 635 +1
Continue to review full report at Codecov.
|
No, I never touched the generic database code here, only the driver-related stuff. |
@acinader The fix for PG should be a simple fix. Transform |
So actually in the validation, we should allow the dot notation / transformation of this sorting no? |
@flovilmart I know this issue #2113 has needed addressing. I can add support for PG order by nested since mongo already does. |
Go ahead, perhaps à PR on @acinader’s or use a branch on this repo so you guys can contribute together |
@acinader @flovilmart I added some additional test. How does this look? |
@dplewis awesome! thanks. @flovilmart comment added. I factored out the operation into a function and commented. Got rid of param reassignment too, bonus. |
Yeah that’s better. I would probably have called it ‘rootFieldName’ but that’s ok as is :) |
yeah, that is a lot better name. see #4817. thanks. |
* add failing test to demonstrate that you can't sort on a field in an object. * Only validate the base of the field name. * fix test name * Only test sort for mongo. * pg order by nested object * level 2 test * Factor out operation to get a field's base name. Add comment. * tweak comment wording so it wont make my grammar teacher angry.
* add failing test to demonstrate that you can't sort on a field in an object. * Only validate the base of the field name. * fix test name * Only test sort for mongo. * pg order by nested object * level 2 test * Factor out operation to get a field's base name. Add comment. * tweak comment wording so it wont make my grammar teacher angry.
…ty#4806) * add failing test to demonstrate that you can't sort on a field in an object. * Only validate the base of the field name. * fix test name * Only test sort for mongo. * pg order by nested object * level 2 test * Factor out operation to get a field's base name. Add comment. * tweak comment wording so it wont make my grammar teacher angry.
fixes: #4805
see
parse-server/src/Controllers/DatabaseController.js
Line 414 in 3b40d22
There is a validation check for the name of a field to make sure that it is valid. This check is performed in both the Schema Controller and the Database Controller. In the database controller, the check is applied when an update or a find operation is requested on the database.
Since updates can occur to and find's can be performed on members of a document, it is important that the check only be performed on the name of the field, and not the member.
In the case of the update, there is an existing split that separates the field from the member.
The split is missing from the find when trying to sort on a field which is erroneously causing an error.
This pull request introduces a test to sort on a member of a document and a fix to allow the test to pass.