We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Given the following mapping:
@Entity({ tableName: 'base', discriminatorColumn: 'type', abstract: true }) export default abstract class BaseMikro { @ManyToOne(() => BaseMikro, { fieldName: 'parentId', wrappedReference: true }) parent: IdentifiedReference<ActivityMikro<any>>; }
This is the compiled output function
if (data.parent === null) { entity.parent = null; } else if (typeof data.parent !== 'undefined') { if (isPrimaryKey(data.parent, true)) { entity.parent = new Reference(factory.createReference('BaseMikro', data.parent, { merge: true, convertCustomTypes })); } else if (data.parent && typeof data.parent === 'object') { entity.parent = new Reference(factory.create('BaseMikro', data.parent, { initialized: true, merge: true, newEntity, convertCustomTypes })); } }
Given the following data
1: parent = null, type = 'Impl1' 2: parent = 1, type = 'Impl2'
When I run a query like the one below:
const implementations = em.find(BaseMikro, {}); assert(implementations[0] instanceof Impl1); // pass assert(implementations[1] instanceof Impl2); // fail (is BaseMikro)
The generated code above doesn't seem to understand it is a discriminated class.
Versions
"@mikro-orm/cli": "^4.5.9", "@mikro-orm/core": "^4.5.9", "@mikro-orm/migrations": "^4.5.9", "@mikro-orm/nestjs": "^4.3.1", "@mikro-orm/postgresql": "^4.5.9", "@mikro-orm/reflection": "^4.5.9",
The text was updated successfully, but these errors were encountered:
Please provide full reproduction for this, this is not enough to reproduce. For example this test basically checks the same.
Sorry, something went wrong.
fix: reproduction test case for (mikro-orm#2364)
6cbfe53
a0827f5
fix(sti): fix prototype of child entity after it gets loaded
e78942a
Related: #2493 Closes #2364
No branches or pull requests
Given the following mapping:
This is the compiled output function
Given the following data
1: parent = null, type = 'Impl1'
2: parent = 1, type = 'Impl2'
When I run a query like the one below:
The generated code above doesn't seem to understand it is a discriminated class.
Versions
The text was updated successfully, but these errors were encountered: