-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Filter not working correctly #3593
Comments
What endpoint are you using this filter? |
Hi, |
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. |
Got similar issue, when I use {"where":{"id":XX}} it returns the correct result. |
Got similar issue, using orgId in Content as foreign key of id in Organisation collection. Using Content.find({where:{ orgId }}) returning [] empty array. Getting results when using other fields like Content.find({where:{ name }}). |
Got similar issue. Here are the details:
Custom Participant model inherited from the built-in User with the following attributes:
where parentUserId is populated with User.id. Receive empty array ([]) where queried using If used with "WHERE" instead of "where", it returns all entities in Participants. Please help. Thanks. |
i'm receiving this exact issue as well. Has anybody found a way around this? |
I suddenly started to present this issue as well, {"where": { "chainId": "598c71f8a61ed73d00756212"}} it returns empty array :(. I believe this will be a datasource-juggler issue. |
The workaround to this problem is to use "Like" clause.
I hope this helps you all. |
@sskhokhar It works. |
Unfortunately the "like" clause workaround doesn't work in my case |
Hello, thank you all for participating in this discussion. Our bandwidth is very limited, therefore it would tremendously help us if somebody could create a sample application that will reproduce the issue - ideally a test that seeds the database with the necessary data, makes the HTTP call(s) and asserts the expected result. See http://loopback.io/doc/en/contrib/Reporting-issues.html#bug-report. The simpler the test cause you can come up with, the easier it will be to identify the root cause. |
I've encountered the same issue: if you want to filter by My mistake has been to declare |
I occasionally face such problems, too. |
Hi all, Here is a simple app which reproduces the issue using mongodb connector: https://github.com/petrgazarov/loopback-sandbox-issue-3593-repro Mongodb connector automatically converts string properties that look like ids to ObjectID types. This is documented in the docs. So then
When I set
Loopback docs should probably mention this gotcha as it is not clear that not setting this flag breaks the |
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. |
@petrgazarov Thank you so much for pointing out. Was facing the same issue and using an hour to figure out how to fix it. Saved my day ! Edit: It happens occasionally, for some models I do not add "strictObjectIDCoercion": true, the issue does not appear. While for some models which is no problem previously, then the issue suddenly appear. This is weird. |
@petrgazarov Shouldn't this flag be true by default in a web framework? This behavior is actually dangerous! |
Yes where in string works for me!
|
in Loopback 4 this is not working. |
i did try to make it ObjectId also but it does not work. |
LoopBack 3 still failing |
This works in LB3, but it doesn't make sense IMO. There are two possible things going on here, doc is wrong and doesn't state that findOne needs an object with the filter property or doc is correct and findOne is bugged.
It'd be nice to have a confirmation on this issue so we can either fix the docs or fix the issue. |
dont use where only { "id":2} work fine |
It worked for me |
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 |
I am having the same issue it only seems to occur for integers when I went into the model and changed the attribute in question to a string [where] works as expected. |
I have the same issue. I have used the work around to use "like" temporarily. I have attached the package.json file to identify if package versions has got anything to do with it.
|
I got to work in this way http://127.0.0.1:3000/users?filter[where][domain]=domain100 without quotes in loopback4 |
Thanks this worked for me also. |
Consider the following model definition:
Model A:
When I apply filter to model A in explorer like
I get the results but when I apply this filter
I get empty array
Even this behavior is seen in filter like
I get empty array.
I tried changing data types from "any" to "string" but still it doesn't work
Please suggest me something on this.
The text was updated successfully, but these errors were encountered: