-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
always escape RegExp when building query in mongoose connector #10499
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10499 +/- ##
=======================================
Coverage 58.01% 58.01%
=======================================
Files 185 185
Lines 6431 6431
Branches 1400 1400
=======================================
Hits 3731 3731
Misses 2236 2236
Partials 464 464
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
Thank you, it looks good to me. Can you please add a test to cover this usecase please? |
@petersg83 sure, I'll take a look at that later this week. |
@petersg83 added it in bea8313 |
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.
Thank you, works perfectly!
Side node: I first tested with mongo 3.6 and the test wasn't failing. I switched to mongo 4.4 and then it failed correctly.
@petersg83 @vkarpov15 After this... This query stop working on my side 😕 {
seasons(where: { slug_contains: "fms-.*-2021-2022" }) {
slug
}
} |
Fix #10348
What does it do?
In a couple places the mongoose connector doesn't escape regexps before passing them to MongoDB
Why is it needed?
See #10348. In short, making a request to
http://localhost:1337/restaurants?name_contains=lorem\
throws an error because of the trailing backslash.How to test it?
Follow the quickstart using MongoDB and make a request to
http://localhost:1337/restaurants?name_contains=lorem\
. Without this PR it will throw an error. With this PR, it will return an empty array as expected.Related issue(s)/PR(s)
#10348