-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Support pointer in distinct query #4471
Conversation
@dplewis The |
@flovilmart I extracted the logic because distinct returns a string like 'TestObject$ObjectId' which returns here. https://github.com/parse-community/parse-server/blob/master/src/Adapters/Storage/Mongo/MongoTransform.js#L1024 Edit: I see what you are saying |
Yeah, I mean what you can do is make a |
I generally do not like this line:
It is dangerous, swallowing all possible errors like that. Also, I probably would replace this block: let qs = `SELECT DISTINCT ON ($1:raw) $2:raw FROM $3:name ${wherePattern}`;
if (isArrayField) {
qs = `SELECT distinct jsonb_array_elements($1:raw) as $2:raw FROM $3:name ${wherePattern}`;
} with this one: const transformer = isArrayField ? 'jsonb_array_elements': 'ON';
const qs = `SELECT DISTINCT ${transformer}($1:raw) AS $2:raw FROM $3:name ${wherePattern}`; |
Codecov Report
@@ Coverage Diff @@
## master #4471 +/- ##
==========================================
- Coverage 92.98% 92.86% -0.13%
==========================================
Files 118 118
Lines 8498 8376 -122
==========================================
- Hits 7902 7778 -124
- Misses 596 598 +2
Continue to review full report at Codecov.
|
Can't see which PR made this one out-of-date, but requested a branch update, since it is required. |
There were node packages that were merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@dplewis Does not work for me.
It just returns records with duplicate content column. |
Well, the single unit test that is exactly what you describe passes. So open a an issue with the full details as well as code examples and relevant logs |
Do your objects have a field called “content.objectId”? Make sure you are querying the right field. Please open an issue with examples and I’ll look it over |
|
@flovilmart |
did you notice that in the test it is:
and in your example:
Well if you don't see the differences now, I'm not sure how to help you. |
Shit, ok got it. |
Well, that's what's written in the test file. Next time consider reading what the maintainers share as well as perhpas the docs: https://docs.parseplatform.org/js/guide/#distinct |
I heard you the first time. |
* Support pointer in distinct query * extract transform pointer string
Per #2238 (comment)
Let me know if theres a better way to implement this.