-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Feature: Delete orphaned rows #1665
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
Conversation
* Fix broken anchor link * Update SqljsConnectionOptions.ts * fix(docs): link to sqljs connection options * Edit Replication document * returns * Update multiple-connections.md * delete orphans implementation * Determine subject removal in builder * lint fixes
|
Im sorry but I cannot accept this PR. First, persistence was completely refactored in If you want have this feature in |
|
I'd personally really like to have this feature in |
…pplication from crashing out (#2) * Handle pool/connection-level errors on different drivers to prevent application from crashing out * Fix stupid stuff
* include tablepath when deleting rows * revert gulp
|
@adenhertog I see you pushed some changes, but as I told if it will be implemented it must be re-implemented against |
|
Hey @pleerock, I'm happy to discuss how this might fit into Can we discuss your concerns on this? if it's something that can be covered by some more tests then I can try to flesh out the scenarios you have in mind |
|
Just for your information, this is a common use-case for me as well, and it would be nice if I could have the option to tell typeorm to delete the orphan entities, since today I am required to do it manually! |
|
Hello Guys, please note that i have looked on this issue from a bug perspective in #1761 and also filed a pull request against @next. Having cascade remove working in these cases is essential. Setting the foreign key to NULL only covers a portion of the possible situations. If cascade remove is not working it basically renders all cascade methods to be unusable. I cannot implement "insert" and "update" one way and have some extra code to fill the missing "remove" part. I can go only full with these features or completely without. |
|
Closing this since master has diverged by a major version. I'd still find it very useful having this addressed in the latest release |
|
I am quite surprised that one of the top JS/TS ORM's does not support orphan removal... |
Also, fix: #1351
This adds an additional option on one-to-many relationships where child entities are deleted, rather than having their foreign key set to null, when removed from their parent.
Many times we have the situation where a parent entity "owns" a child. An example of this is when a
Userhas a set ofRoleAssignmentin the context of permissions. When aRoleAssignmentis removed from the user, we expect for the row to be deleted. Previously the row would remain in the database but with theuserIdcolumn set to null, leaving an orphaned row that would clog up the table.This fix allows for
RoleAssignmentto specify on its relationship withUserthat it should be deleted, rather than orphaned, when the relationship is removed.By default, the original behaviour of setting the foreign key to
nullis retained.