-
Notifications
You must be signed in to change notification settings - Fork 236
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
Multiple where filters on one property are ignored #583
Comments
users.json.zip |
Related issue: loopbackio/loopback-next#5244 |
Hello 😸 |
use like: |
Sorry for the late reply. I hadn't found time to investigate it. I quickly checked it and can reproduce the issue. As @wangsenyan suggested, the following would work:
And you're right, the issue is causing by how we build the query (related code). That's why only the first operator gets applied. The issue looks valid to me as it is intuitive for MongoDB users. However, I don't think we bandwidth to improve it in a short time :( |
If you happen to have any proposal, feel free to submit a PR and ping me! Thanks! |
Hello, Thanks for the reply, I started working on something here => https://github.com/gabjauf/loopback-connector-mongodb Trying to find some bandwidth too haha 😄 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the |
Hello Loopback team!!
Just found an example on this page about querying data with multiple filters:
https://loopback.io/doc/en/lb3/Querying-data.html
filter(data, {where: {input: {gt: userInput.min, lt: userInput.max}}})
But tried it on my local LB3 app and could not make it work, it seems to take only the first argument (aka "gt").
Would be awesome to get it to work as it simplifies queries a lot (avoiding us to use the "and" operator)
Steps to reproduce
Typically on a new loopback 3 application:
{ "where": { "username": {"like": "a"}}, "fields": ["username"]}
expects: aa, ab, ac, ad, ae, ba{ "where": { "username": {"neq": "ae"}}, "fields": ["username"]}
expects: all but ae{ "where": { "username": {"neq": "ae", "like": "a"}}, "fields": ["username"]}
expects: aa, ab, ac, ad, baFor the gt / lt / lte / gte
{ "where": { "username": { "gt": "b"}}, "fields": ["username"]}
expects: ba, bb, bc, bd, be{ "where": { "username": { "lt": "bc"}}, "fields": ["username"]}
expects: all but bc, bd, be{ "where": { "username": { "lt": "bc", "gt": "b"}}, "fields": ["username"]}
expects: ba, bbCurrent Behavior
Currently, results of 3rd request are exactly the same as 2nd.
Expected Behavior
We should not have the same results.
Additional information
darwin x64 12.16.3
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
Also, it seems there are 2 bugs in here when I use the VSCode debugger on the "buildWhere" method:
It seems related to these lines:
mongodb.js -- line 958
Related Issues
Did not find any.
I hope it is accurate enough, do not hesitate to reach me 😉
The text was updated successfully, but these errors were encountered: