Filter logic in hasManyThrough & hasAndBelongsToMany (where/include vs order/limit)
Description/Steps to reproduce
phys has many client through appointment
GET /phys/:id/client
filter = {
"where":[some constraint],
"include":[some relation on child]
"limit": 2,
"order" : [some child property]
}
Expected result
All filters are applied to the client model
The fact is that the "include" and "where" is correctly added to the child model call, but the "order" and "limit" are added to the call on the through model.
Result is: "order" will not work as expected or result in a "ER_BAD_FIELD_ERROR" (if SQL) "limit" will limited the number of client FK's evaluated and if no client match the where filter, the result length will be 0, even though clients exist that match the criteria
Additional information
https://github.com/proreact-mj/loopback-sandbox.git
http://localhost:3000/api/phys/1/client?filter={"where":{"name":"Miss H"},"limit": 2} returns []
http://localhost:3000/api/phys/1/client?filter={"where":{"name":"Miss H"},"limit": 8} returns: [{"id":8,"name":"Miss H"}]
hi @proreact-mj thank you for the sandbox repo, I noticed that you created this issue in May, and we backported a fix to juggler and released it as 2.55.0 in July, could you try if the latest [email protected] fixes your problem?
Glorious. It seems that the issue has been fixed. Thanks for the feedback.