-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
matching doesn't set _populated to true #5559
Comments
A workaround for your repro would be using await orm.em.populate(user, ['groups.permissions'], {
where: {
groups: {
permissions: {
write: true,
},
},
},
orderBy: {
groups: {
permissions: {
id: 'ASC',
},
},
},
}); Note that you need to call this on the root entity ( |
Will it affect the loaded groups? I have a where condition on those as well? |
Why don't you check the query yourself? It should be equivalent (it's actually a better approach in general). |
@B4nan, how can I limit populate from populating an entire collection? I want to just take 1 for example. |
So, here is a conversion of your suggestion:
|
Hello @B4nan , have you had a chance to see my comment above? Is there any chance I limit the populate for |
you can't do that with i think i have a workaround for you, you could use await users[0].groups.matching({ ... });
// @ts-ignore accessing private variables and methods
orm.em.entityLoader.setSerializationContext(users, [{ field: 'groups', children: [{ field: 'permissions' }] }], {}); |
Describe the bug
_populated is not set to true when using matching with populate and populateWhere which leads
.toJSON
to strip off the populated entitiesReproduction
https://github.com/SDAdham/reproduction/blob/master/src/example.test.ts
What driver are you using?
@mikro-orm/mysql
MikroORM version
6.2.5
Node.js version
20.9.0
Operating system
No response
Validations
The text was updated successfully, but these errors were encountered: