-
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
Querying associated model with scope and limit #1744
Comments
Please post questions at https://groups.google.com/forum/#!forum/loopbackjs. See https://github.com/strongloop/loopback/wiki/Questions for more details. |
@superkhau : I ll do that, but this looks like an issue to me. |
Can you provide a link to a test project on GitHub? See https://github.com/strongloop/loopback/wiki/Reporting-issues#bug-report |
@superkhau : My bad. should have checked that. Here is the test project: https://github.com/geekguy/loopback-sandbox |
try to explicitly define keyThrough property |
@Neil-UWA : Not sure what you mean. Can you please elaborate? |
@geekguy, sorry, I thought you're using has many through relation. I had this problem when defining has-many through relation without defining key through before. |
@superkhau : Did you get a chance to verify this? |
Hi @geekguy, Thanks for reporting this issue. It definitely seems a bug to me. Also, it is worth mentioning the following examples based on your models:
However:
I'll label it as a bug. Thanks for reporting it! |
Another similar issue to this with scope, limit If you have a 200 model products and each has 1 related model "image" attached to it. And you put scope: limit: 100 on the images model. Then you query like this:
This will give you 200 products, but only the first 100 products will have the image attached. The next 200 will have an empty array. |
@jsheely : Yes. That's the exact issue. |
The include filter seems to be all over the place. I am having some problems with it and embedded models. I am currently seeing if there are any solutions to my problem and if so I will open a new issue or possibly post back here. |
I am having the same issue. This seems to be a bug in
Now suppose i want to get wishlistId = 56bdab621f386c1307f4389d GET request : -
|
@loay Any updates on this task? |
Issue cannot be reproduced in Loopback 3 and neither in LB2 Loopback 2 app:
with limit 2:
Loopback 3 app:
with Limit 2:
|
Closing this issue. If you have a reproduction that can demonstrate the problem, please page @loay or myself (@kjdelisle) and post the repo link here and we'll reopen this. |
Here is the test project: https://github.com/geekguy/loopback-sandbox (Details in readme)
Lets say we have 3 models, M1, M2 and M3 and instances are m1, m2 and m3.
M1 hasMany M2 and M2 hasMany M3.
Now. I want M2s for a given M1 and I want to include M3 with some condition.
This returns all m2s and includes m3s with matching condition which is perfect.
Now I wan only one m3 per m2. So I ll add
limit: 1
But this call has some issues. It returns 1 m3 for first m2 and 0 for rest of them.
If I change
limit: 2
, it returns 1 m3 for first two m2 and 0 for rest of them.Looks like scope condition is going wrong.
Please correct me if I missed anything or doing something wrong.
https://docs.strongloop.com/display/public/LB/Querying+related+models#Queryingrelatedmodels-Usingfiltersparameterswithincludedrelations
The text was updated successfully, but these errors were encountered: