loopback-next
loopback-next copied to clipboard
@loopback/repository 6.1.4 broke hasManyThrough relations
Describe the bug
After the release of @loopback/repository 6.1.4 about 6 hours ago, my hasManyThrough relations stopped working.
After a quite good amount of hours addressing the issue, got suspicious about this line: https://github.com/loopbackio/loopback-next/blob/master/packages/repository/src/relations/has-many/has-many-through.inclusion-resolver.ts#L271
Please note that i'm using mongodb and both ids, foreign keys are implemented via objectId. In one of the cases, the intersection fails when "targetEntityIds" is represented by a string array, while relatedIds is represented by a ObjectId array. The intersecion fails, returning empty arrays.
Version 6.1.3 of @loopback/repository does not present the problem, i suspect it was introduced via commit https://github.com/loopbackio/loopback-next/commit/34f8201efecfd3973fac354c6ef7765630f72db3
Logs
No response
Additional information
No response
Reproduction
Repository: https://github.com/ivanvaccari/lb4-HasManyThrough-test
Run the following sequence of rest calls:
-
POST /contact body:
{ "value": "[email protected]"}
-
POST /contacts/{previousContactId}/people body:
{ "name": "John", "age": "wayne"}
-
GET /contacts/{previousContactId}/people corectly return related models
-
GET /contacts filter:
{where: {id: previousContactId }, include:[{"relation": "people"}]}
Does not return correctly related models. Expecting the same output as of point 3.
@ivanvaccari, thanks for reporting that.
@achrinza @nabdelgadir, the commit mentioned above belongs to https://github.com/loopbackio/loopback-next/pull/8251. any thoughts?
Updated initial post with reproduction example.
Thanks @ivanvaccari. Would you be interested in submitting a PR to fix the problem?
Are there updates on this topic?