Skip to content
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

@loopback/repository 6.1.4 broke hasManyThrough relations #10259

Closed
ivanvaccari opened this issue Dec 12, 2023 · 4 comments · Fixed by #10469
Closed

@loopback/repository 6.1.4 broke hasManyThrough relations #10259

ivanvaccari opened this issue Dec 12, 2023 · 4 comments · Fixed by #10469
Labels
bug regression Repository Issues related to @loopback/repository package

Comments

@ivanvaccari
Copy link

ivanvaccari commented Dec 12, 2023

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 34f8201

Logs

No response

Additional information

No response

Reproduction

Repository: https://github.com/ivanvaccari/lb4-HasManyThrough-test

Run the following sequence of rest calls:

  1. POST /contact
    body: { "value": "johnwayne@gmail.com"}

  2. POST /contacts/{previousContactId}/people
    body: { "name": "John", "age": "wayne"}

  3. GET /contacts/{previousContactId}/people
    corectly return related models

  4. GET /contacts
    filter: {where: {id: previousContactId }, include:[{"relation": "people"}]}
    Does not return correctly related models. Expecting the same output as of point 3.

@dhmlau
Copy link
Member

dhmlau commented Dec 12, 2023

@ivanvaccari, thanks for reporting that.

@achrinza @nabdelgadir, the commit mentioned above belongs to #8251. any thoughts?

@ivanvaccari
Copy link
Author

Updated initial post with reproduction example.

@achrinza achrinza added Repository Issues related to @loopback/repository package regression labels Dec 13, 2023
@dhmlau
Copy link
Member

dhmlau commented Dec 13, 2023

Thanks @ivanvaccari. Would you be interested in submitting a PR to fix the problem?

@ivanvaccari
Copy link
Author

Are there updates on this topic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug regression Repository Issues related to @loopback/repository package
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants