-
-
Notifications
You must be signed in to change notification settings - Fork 610
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When using a custom typed PK (see #1798), ManyToMany using a pivotTable doesn't work. The map returned from
await this.driver.loadFromPivotTable()
does not contain converted keys and thus the lookup fails.
map[entity.__helper.getSerializedPrimaryKey()]
is undefined.
Stacktrace
TypeError: Cannot read property 'map' of undefined
at EntityLoader.findChildrenFromPivotTable (/app/node_modules/@mikro-orm/core/entity/EntityLoader.js:232:69)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async EntityLoader.populateField (/app/node_modules/@mikro-orm/core/entity/EntityLoader.js:185:25)
at async EntityLoader.populate (/app/node_modules/@mikro-orm/core/entity/EntityLoader.js:37:13)
at async EntityLoader.populateField (/app/node_modules/@mikro-orm/core/entity/EntityLoader.js:203:9)
at async EntityLoader.populate (/app/node_modules/@mikro-orm/core/entity/EntityLoader.js:37:13)
at async SqlEntityManager.find (/app/node_modules/@mikro-orm/core/EntityManager.js:105:9)
at async EntityLoader.populateMany (/app/node_modules/@mikro-orm/core/entity/EntityLoader.js:127:22)
at async EntityLoader.populateField (/app/node_modules/@mikro-orm/core/entity/EntityLoader.js:187:9)
at async EntityLoader.populate (/app/node_modules/@mikro-orm/core/entity/EntityLoader.js:37:13)
To Reproduce
Steps to reproduce the behavior:
Create the entities with the custom type from #1798.
export class Product {
@PrimaryKey({ type: UuidBinaryType, name: 'uuid' })
id: string;
@ManyToMany({
owner: true,
entity: () => Field,
pivotTable: 'product_order_field',
joinColumn: 'product_id',
inverseJoinColumn: 'order_field_id',
})
fields: Collection<Field> = new Collection<Field>(this);
}
export class Field {
@PrimaryKey({ type: UuidBinaryType, name: 'uuid' })
id: string;
@Property()
title: string;
}
- Fetch products with its fields from the database.
Versions
| Dependency | Version |
|---|---|
| node | 14.16.1 |
| typescript | 4.2.3 |
| @mikro-orm/core | 4.5.6 |
| @mikro-orm/mysql | 4.5.6 |
| @mikro-orm/nestjs | 4.2.0 |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working