mikro-orm-soft-delete
mikro-orm-soft-delete copied to clipboard
Relationships not updated correctly
I have a Foo entity with a OneToOne relation to a Bar entity.
When hard-deleting Foo, Bar is deleted due to having deleteRule: 'cascade'.
When soft-deleting Foo, Bar is not deleted and it's deletedAt property is not updated, only Foo's deletedAt.
HOWEVER: If I attempt to fetch Bar, the orm doesn't find it, even when its deletedAt property is still undefined. If I disable filters, it's fetched correctly.
So it seems it's working half way. Am I missing something? Is there a standardized way I should be cascading soft deletions? I'm only using deleteRule: 'cascade'. No orphan removal.
Hey @Jcalcaldev thanks for the feedback. I'm extremely occupied these days. Will look into it after March 1st.
I'm not pretty sure whether the deletedAt property of the relation entity should be updated. Currently, since we have filtered out all the deleted Foo entities from the queries, the Bar entity is expected not to appear in the query result, and I think it is an acceptable behavior since it makes it easier to recover soft-deleted entities - you only need to set deletedAt to undefined on one entity.
I do understand that it might be confusing at the data level, since the entity is in fact soft-deleted but its deletedAt property does not have a value, but currently I don't find a good reason to update the behavior.
Please let me know if there are any other troubles caused by this behavior.