You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can populate the country property from the side of the User, but you cannot populate the users collection from the Country's side.
Expected behavior
One should be able to populate the users collection also from the Country's side.
Additional context
Here is a test suite that explains everything in detail:
import{MikroORM}from'@mikro-orm/core'import{SqliteDriver}from'@mikro-orm/sqlite'import{Address}from'./address'import{Country}from'./country'import{User}from'./user'describe('Issue',()=>{letorm: MikroORMbeforeAll(async()=>{orm=awaitMikroORM.init({entities: [User,Country,Address],dbName: ':memory:',driver: SqliteDriver,allowGlobalContext: true,})awaitorm.schema.createSchema()})afterEach(async()=>{awaitorm.schema.clearDatabase()})afterAll(()=>orm.close(true))beforeEach(async()=>{constgermany=orm.em.create(Country,{name: 'Germany'})orm.em.create(User,{name: 'John Doe',address: newAddress('Main Street','Berlin',germany)})awaitorm.em.flush()})test('the country can be populated through the address of a user',async()=>{constuser=awaitorm.em.findOneOrFail(User,{name: 'John Doe'},{populate: ['address.country']})expect(user.address.country.name).toBe('Germany')})test('the users can be populated through the address of a country',async()=>{constcountry=awaitorm.em.findOneOrFail(Country,{name: 'Germany'},{populate: ['users']})expect(country.users[0].name).toBe('John Doe')// ❌ this one fails})test('can init the user collection of a country',async()=>{constcountry=awaitorm.em.findOneOrFail(Country,{name: 'Germany'})awaitcountry.users.init()expect(country.users.isInitialized()).toBe(true)expect(country.users[0].name).toBe('John Doe')})})
Versions
Dependency
Version
node
16.15.1
typescript
4.9.5
mikro-orm
5.6.13
sqlite3
5.1.4
The text was updated successfully, but these errors were encountered:
This is not supported - you could tell by the need to cast things to any to be able to define this. You can't define inverse side of such relation because embedded entity does not have a primary key, hence it has no identity.
I'll keep this open as a feature request, as it could work for inlined mode. It is partially connected to #3887, the root cause is the same.
Describe the bug
Hey there! First of all, thanks a lot for this very stable and intuitive TS ORM! ❤️
Since a couple of versions, an
@Embeddable
can have a@ManyToOne
relationship through its parent. This works fine.However, the inverse side that would use a
@OneToMany
collection cannot populate the user.Stack trace
To Reproduce
Here is an example setup:
You can populate the
country
property from the side of theUser
, but you cannot populate theusers
collection from theCountry
's side.Expected behavior
One should be able to populate the
users
collection also from theCountry
's side.Additional context
Here is a test suite that explains everything in detail:
Versions
The text was updated successfully, but these errors were encountered: