loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Filter logic in hasManyThrough & hasAndBelongsToMany (where/include vs order/limit)

Open proreact-mj opened this issue 9 years ago • 2 comments

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"}]

proreact-mj avatar May 19 '17 15:05 proreact-mj

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?

jannyHou avatar Aug 10 '17 21:08 jannyHou

Glorious. It seems that the issue has been fixed. Thanks for the feedback.

proreact-mj avatar Aug 11 '17 07:08 proreact-mj