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

Populate doesn't work with refs #302

Closed
stephenh opened this issue Jan 17, 2020 · 1 comment
Closed

Populate doesn't work with refs #302

stephenh opened this issue Jan 17, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@stephenh
Copy link

stephenh commented Jan 17, 2020

I have a parent/child relationship but populate is not working because the child's mappedBy/ManyToOne is modeled with an IdentifiedReference.

I.e. in the child, I have:

  @ManyToOne({ entity: () => Parent, wrappedReference: true })
  parent: IdentifiedReference<Parent>;

When I try to preload the OneToMany collection on the other side of this relation (i.e. loading multiple Parents and using populate: ["children"], none of the Parent.children collections are populated correctly b/c this line is failing to match:

const items = children.filter(child => child[(prop.mappedBy)] as object === entity);

https://github.com/mikro-orm/mikro-orm/blob/master/lib/entity/EntityLoader.ts#L76

Because the child["parent"] is trying to match on entity, and entity is a Parent instance, but the child["parent"] field is an IdentifiedReference.

@stephenh stephenh added the bug Something isn't working label Jan 17, 2020
@B4nan B4nan closed this as completed in d048b64 Jan 18, 2020
@B4nan
Copy link
Member

B4nan commented Jan 18, 2020

Thanks for the report. Will release this early next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants