-
Notifications
You must be signed in to change notification settings - Fork 83
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
Regression in string matching in 4.3 #355
Comments
Hi @JoelCourtney, thanks for the report. Your query is incorrect but due to weak input validation the library does not throw an error. Only a single operator is processed when specified for a field, which in this will be the The string The behaviour in Also the value for |
@kofrasa Thanks for responding. My bad with the let query = new Query({
num: {
$gt: 0,
$ne: 5
}
});
console.log(query.test({
num // see below
})); When EDIT |
Both operators are applied and ANDed together however the results you described is wrong. The outputs should be true for both 1 and 3, and false for 5. Perhaps you are still testing on |
Ah that was a typo, I meant
Those statements seem to directly contradict each other. Why does this query only apply one operator and ignores the other: str: {
$regex: ".*MATCH",
$ne: "NOT_A_MATCH"
} But this query applies both: num: {
$gt: 0,
$ne: 5
} |
Sorry for the confusion. The first statement is false in the context of using the The first statement is only true for pipeline and expression operators. |
Thanks for clarifying. Then do you agree that there is a bug here? Here's a section from the mongo docs that uses the exact same pattern that I'm trying to use. If you use this query in mingo 4.3 or higher: |
Yes there is a bug. I see what you mean. The behaviour is inconsistent specifically with $regex matching. |
I am trying to match a string with regex, but with an exception for a specific string like so:
In 4.2 this query correctly returns
false
. In 4.3 and later this now returnstrue
. In this simple case I can workaround by removing the$not
and making the regex a little more complex, but this still seems like a bug.The text was updated successfully, but these errors were encountered: