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
V6. When using STI, and two different children of an STI have properties referencing different children of another STI, an error can occur on update #4440
Comments
That repro is wrong, you can't use a detached entity this way, const manager = new Manager();
manager.email = 'bbb@aaa.com';
manager.managerCollaborators.set([orm.em.getReference(ManagerCollaborator, 1)]);
await orm.em.flush(); Or in a single step via const manager = orm.em.create(Manager, {
email: 'bbb@aaa.com',
managerCollaborators: [1],
});
await orm.em.flush(); |
Maybe we could treat entities managed by a different fork as a reference automatically, so your code would work automatically. |
The bug occurs even without the em.clear(). I added that when I was trying to figure out from where the bug came from. |
Can you please re-open the issue @B4nan ? |
The repro is still kinda wrong, you can't redefine a property in the child class, as all the child classes are merged to the base entity type, and that is used internally. This is a known problem, there are other open issues about that, e.g. #2388. I want to look into that in v6 too. |
FYI with #4769 your new test is also passing. |
Describe the bug
The scenario:
When fetching a ManagerCollaborator, the __originalEntityData will contain two entries with the same data, __originalEntityData .manager and __originalEntityData .employee because the are referencing the same column, even though the property employee does not exist in Manager
if you set this fetched managerCollaborator as a relation of another entity, and flush, the diff between the original data and the current data will get discovered and the EntityManager will try to update the entry.
To Reproduce
Steps to reproduce the behavior:
https://github.com/YanDjin/mikro-orm/blob/bug/sti-update/tests/issues/GH4440.test.ts
this test replicates the issue.
Expected behavior
The em should not make the diff using the columns of another child of the STI
Versions
The text was updated successfully, but these errors were encountered: