-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Remove entity using cascade options #151
Comments
There is one small bug I know with cascade remove in one-to-one relations. It should work fine with many-to-one/one-to-many relation, but does not in one-to-one relation. Maybe its because of that. I'll try to fix it this week. Would be great if you provide a minimum code that produces your error |
I reproduced it with minimum code. Naturally, you'll need to change the db connection details in app.ts and recompile, and execute npm install to install the required dependencies. Notice the rows in the db tables once you run node. |
Hey, any news about this? |
fixed and released in |
Would it be possible to allow having remove cascade options on both sides of the relation (since both can be needed under different circumstances) and break circular removals when they happen? |
cascade removes are real pain. if you set cascade remove from both sides it will be logically incorrect. If you just set |
I understand the circular issue, but what I'm suggesting is that you track which relation caused the removal of an entity, and if that removal causes further removals that contain the removing entity, exit the recursion. |
I don't think that preventing it from removing is correct behaviour either. |
For me it'd feel intuitive, but I guess that's very subjective. Wouldn't it be better than not allowing it altogether? |
Anyhow, it doesn't work for me also when there's no circular issue and it's defined only on one side of the relation. |
this issue is not completely resolved, I'll return back to it in the near future |
per our discussion with @AlexMesser we are removing cascade remove functionality from ORM scope. You must use |
I have 2 entities - EntityA and EntityB, they have a OneToOne relation with cascade options:
EntityA.ts
Cascade options work for insert and update so far, but how do I make it work for remove?
For instance, I have:
var entityA: EntityA = *finding in repo, inner join and select entityB*;
entityA.entityB exists.
I tried to then null it like that:
entityA.entityB = null;
When I persist entityA, it simply breaks the connection between the entities (makes sense).
I'd like it to remove entityB, similarly to:
entityBRepository.remove(entityB);
How do I do that?
The text was updated successfully, but these errors were encountered: