-
-
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
Improve Tree Entities feature set (adding update and remove logic) #7155
Labels
Comments
mateussilva92
added a commit
to mateussilva92/typeorm
that referenced
this issue
Dec 5, 2020
Allows tree entities relations to be updated and deleted via the save function from the Repository Closes: typeorm#7155
7 tasks
Will this also close #193? |
It will, adding it to the closing list, thanks. |
Any prevision? This is a good feature! |
AlexMesser
pushed a commit
that referenced
this issue
May 18, 2021
* feat: add tree entities update and delete logic Allows tree entities relations to be updated and deleted via the save function from the Repository Closes: #7155 * fix: fix linting errors * fix: revert development changes * fix: remove commented code * fix: remove LIMIT 1 to fix Oracle test * fix: fix mssql onDelete CASCADE for the closure juntion table * fix: add a await insert to the junction table query * feat: add closure junction cascade for all drives except mssql Mssql uses a conventional delete to manage the junction table Allow TreeParent onDelete CASCANDE on all drivers except mssql, mssql will throw an error saying that the feature is not supported. * fix: add try catch to getMetadata on createForeignKey in SqlServerQueryRunner * fix: fix entities path typo * fix: fix issue regarding relation in for tree entities * fix: make tree relation tests run in all drivers * fix: fix tests by setting relation tree entities in a new file * fix: enable re-adding a parent to an entity with a previous null parent * refactor: replace a try catch with a ternary operator
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature Description
The Problem
So, the Tree Entities are missing a lot of functionality. Namely they have no logic for update nor delete. Meaning that if you make changes between the relation of the entities the changes are not reflected in the database.
This happens for any of the tree approach we use (closure table, nested sets and materialized paths).
The Solution
Implement all the logic to update and delete any changes to the tree structure. This will require creating at least some functions for updating and, in the case of the nested sets, one for deleting in the tree subject executors.
This will also require additional changes to the main subject executor to allow the execution of updates for the nested sets in series instead of parallel like the other updates are done. The main reason for this change is that we need to make sure that the changes are done one by one since a change in the tree could also affect other entities in the tree that are not directly connected and if we have multiple updates at once it will screw things up.
Those are the two main changes.
Additional Context
For additional context I would like to add some points for things that might have changed or are just not introduced with this new feature.
Note:
This feature will also fix issue #193, #2032, #2418, #3691, #3988, #4174, #4353, #5268 and #6118.
This feature is duplicated by #3556 for updating materialized-path tree repositories.
Relevant Database Driver(s)
I'm not sure about which databases support Tree Entities, you guys can probably help me here.
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: