Skip to content
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

Questions around cascades and soft deletes #6139

Closed
maclockard opened this issue May 26, 2020 · 8 comments
Closed

Questions around cascades and soft deletes #6139

maclockard opened this issue May 26, 2020 · 8 comments

Comments

@maclockard
Copy link

Issue type:

[x] question
[ ] bug report
[ ] feature request
[x] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Question
I have a couple questions around relation cascades that are not answered by the documentation.

  1. What's the difference between setting cascade: "remove" and setting onDelete: "CASCADE"?
  2. Does setting onDelete: "CASCADE" cause soft deletes to cascade as well? or can that only be specified using the cascade option.
  3. Does cascade: "recover" mean that recovering a soft deleted object will cascade the recovery?
@maclockard maclockard changed the title a Questions around cascades and soft deletes May 26, 2020
@imnotjames
Copy link
Contributor

For questions, please check out the community slack or check TypeORM's documentation page on other support avenues - cheers!

@jbjhjm
Copy link
Contributor

jbjhjm commented Oct 13, 2021

Sorry @imnotjames, I have to disagree in this case. Documentation is very incomplete when it comes to cascades and what does what. Github issues is the #1 go-to knowledge base for everything that's not documented, while community slack is all about individual issues and hard to use if you search for information.

Neither here, nor in the documentation, nor on discord was I able to find useful information on what the newer cascade types actually do. Guess I'm on my own here. Will try to pull to documentation if I find out how it is supposed to work.

@maclockard
Copy link
Author

Yeah, I thought these were broad enough questions to be included in the documentation rather than answered in slack. It doesn't make sense for everyone wanting to know how cascades work with typeorm to separately post in a slack channel.

@jbjhjm
Copy link
Contributor

jbjhjm commented Oct 13, 2021

Agreed @maclockard . I'm right now making notes on what does what but it is not easy to grasp how all these settings work together. I'll possibly post info/questions here to discuss what is correct.

@imnotjames
Copy link
Contributor

imnotjames commented Oct 13, 2021

Sorry @imnotjames, I have to disagree in this case. Documentation is very incomplete when it comes to cascades and what does what. Github issues is the #1 go-to knowledge base for everything that's not documented, while community slack is all about individual issues and hard to use if you search for information.

Neither here, nor in the documentation, nor on discord was I able to find useful information on what the newer cascade types actually do. Guess I'm on my own here. Will try to pull to documentation if I find out how it is supposed to work.

GitHub issues are for reporting issues, not asking questions. It's not kept up to date and does not lead well to workflows. The issues are not stack overflow QAs.

We removed the question type because it was leading to thousands of questions that were unanswered, causing us to lose the ability to track actual issues, and had many cases with unclear feature requests disguised as questions which weren't actionable.

@maclockard
Copy link
Author

I don't care if you answer the question here. I agree github issues are a poor knowledge repository.

I am making a request the documentation be brought up to date. It's very confusing to include two different features that share a name (cascasde) but (might?) function differently. A simple sentence explaining the difference or saying cascade: "remove" and onDelete: "CASCADE" would go a long way. Additionally, the current documentation doesn't specify how the cascade option recover interacts with soft-deletes.

I could experimentally verify the behavior, but then I wouldn't know if the current behavior is intended or a bug, nor would a non-maintainer answering a question over slack. It's important to specify how a feature is supposed to work somewhere, and I thought in documentation would make sense.

My guess of how those features differ
  • cascade: "remove" is a typeorm feature that performs cascades if and only if deletes are done via typeorm.
  • onDelete: "CASCADE" uses the underlying storage's cascade functionality via a migration, so that things cascade regardless of if you use typeorm.
  • onDelete: "CASCADE" does not propagate soft deletes
  • recover only recovers soft-deletes

But not 100% confident that the above is true and not confident that any of the above behavior isn't unintended.

@imnotjames
Copy link
Contributor

I am making a request the documentation be brought up to date.

I understand that now, but my initial reading of the issue did not make it seem as such. The initial reading was that this was a request for clarification beyond what reasonably can be documented.

If you'd like to open a new issue explicitly requesting the documentation be improved and how I'm happy to have that in the backlog.

@jbjhjm
Copy link
Contributor

jbjhjm commented Oct 13, 2021

I agree on issues being a bad place to search for knowledge - though typeOrm is a complex beast and looking for answers to my problems, searching the issues has often been more successful than checking the official documentation.

I'm currently gathering all knowledge on cascade system(s) that I have and can find and will open a new issue/PR then. Though I think I'll need a bit of help to completely document the behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants