mikro-orm: OneToOne is not cascaded correctly
Describe the bug If you create a new object with a OneToOne relation and persist that object, the items are persisted but the relation id’s are still empty.
For example:
const newEnt1 = wrap(new Enitity1()).assign({
prop1: req.body.prop1,
ent2: {
prop: req.body.prop,
}
});
This creates a row for ent2 in the database but it doesn’t fill the foreign keys (ent2.ent1_id is NULL) (doesn’t work if ent1 is owner of the relation nor if ent2 is. I expected something like the collections, that it fills the id’s as well.
Am I doing something wrong or is this not supported?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (23 by maintainers)
Commits related to this issue
- fix(core): allow persisting 1:1 from inverse side Closes #210 — committed to mikro-orm/mikro-orm by B4nan 5 years ago
I can’t replicate this, works as expected for me, all entities are properly cascaded and stored. Where do you get this error from? Please post a stack trace. Or ideally prepare reproduction repository.
Generally would be nice if you follow the bug report issue template, I am asking for that information because it will help me a lot when understanding what happens. I am not even sure what driver you are using.