-
-
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
fix aggregate geoNear with date query #6540
fix aggregate geoNear with date query #6540
Conversation
- geoNear stages were not parsed for date fields, but mongodb nodejs adapter requires date object
Codecov Report
@@ Coverage Diff @@
## master #6540 +/- ##
==========================================
- Coverage 94.02% 94.01% -0.01%
==========================================
Files 169 169
Lines 11848 11850 +2
==========================================
+ Hits 11140 11141 +1
- Misses 708 709 +1
Continue to review full report at Codecov.
|
@dplewis Could you take a look at this? Test before the fix failed as expected.
I cannot find out where that split is. |
What version of Mongo are you running locally? |
4.2.3
|
- the geoNear object contains parameter keys which could be identical to field names in the collection, which should not be parsed and changed, therefore restricting parsing only to query parameter key
I am using VS Code to debug, but I didn't manage to set breakpoints when testing, or even run only a single test using the Test Explorer instead of all tests of a file with |
@dplewis Any help appreciated, I am stuck here unfortunately :/ |
@dplewis I should clarify that the test fails also locally with he same error. However, the code fix itself works and returns the correct results when running a query in cloud code. |
- required to create geo index for geoNear test
- test case likey failed due to date rounding
- temporary, to find out why test fails on mongodb 3.6.9
- mongodb <4.0 does not allow nultiple geo indices on a class when using geoNear - see https://docs.mongodb.com/v3.6/reference/operator/aggregation/geoNear/#behavior
- results were not ordered properly, so test validation failed sometimes
This reverts commit da81c51.
The geo near query failed due to missing geo index, which is required for Ready to merge. |
@acinader Can we get this into the next release? |
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!
Hey Guys, i think this broke geoNear. I had I tried the same query directly on mongo and it worked, the query was very basic just to test, after searching i saw that this PR changed geoNear so i tried the version before(4.1.0) and it worked with the same query, went back again to 4.2.0 to confirm and got the same error. This is the pipeline i was trying: const query: any[] = [
{
geoNear: {
near: [-73.99279, 40.719296],
distanceField: 'distance',
maxDistance: 1000,
spherical: true
}
}
]; |
I'm running |
I think maybe you forced the |
@matheusdavidson Thanks for reporting, can you please open a new issue regarding this and reference this PR? I will look into this in the meanwhile. |
Interesting, I added test cases without the |
Strange, had another team member with that same problem with a version of our app without downgrading to 4.1.0. geoNear won't work anymore in the latest version |
@matheusdavidson Are you or your team member able to replicate or observe this currently? It could also depend on the version of nodejs or mongodb driver. Sent with GitHawk |
@matheusdavidson Can you please open an issue for this and post your findings there? If we discuss it here is only has limited visibility. Sent with GitHawk |
i'm gonna do that. Just had the same problem now on another project using geoNear, will have to lock the version on 4.1.0 on all projects here. |
@matheusdavidson Do you have any update on this issue? If not, I will go ahead and close the related PR. |
Hey @mtrezza, i didn't had time to see why this is happening but i'm sure the PR broke geoNear as i stated, for now what i did was downgrade all the projects to 4.1.0. Had lots of late projects and couldn't spend more time on this. Will open an issue in the future. |
…efined see dicussion in parse-community#6540
@matheusdavidson Since I was not able to reproduce this issue with the test cases in #6696, I added a potential fix for this potential issue by changing: if (stage.$geoNear) {
stage.$geoNear.query = this._parseAggregateArgs(schema, stage.$geoNear.query);
} to if (stage.$geoNear && stage.$geoNear.query) {
stage.$geoNear.query = this._parseAggregateArgs(schema, stage.$geoNear.query);
} So It would be great if you could upgrade a project to Parse Server 4.2.0 to confirm that it fails and then deploy the Parse Server master branch with PR #6696 merged. Then we'd know for sure whether the issue is solved. |
@mtrezza thank you for adding the fix, i will upgrade one of the projects and test today. |
@matheusdavidson That would be great. Note that the PR is not merged into master yet, but you can use the PR branch. |
Hey @mtrezza, sorry it took so long for me to test. That solves my problem, thank you for your efforts!! |
@matheusdavidson Thanks for your feedback, glad it worked. |
* add test cases for geoNear aggregation Test cases do not have the `query` parameter set in $geoNear aggregation stage. this is to test for a reported potential issue when the parameter is not set. * fixed potential issue when setting the geoNear.query parameter to undefined see dicussion in #6540 * fixed duplicate index name in test
added failing test case