-
-
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
Breaking change for many-to-many relationships in 0.2.33 #7745
Comments
I am also having trouble with this version number, although my problem is that TypeORM doesn't see any changes when it should. My only worksround currently is to use TypeORM 0.2.32. I don't have time to get into details right now, but could try to provide more if needed. |
Isn't this more correct? Shouldn't cascading deletes be EXPLICITLY defined because of how destructive / dangerous they are? |
@imnotjames It might be, because you're right, all other FK relationships require one to explicitly set the cascading behavior. But a couple things:
Part of the reason for opening this issue was to get clarification on this. I'm fine if the answer to point 1 is "won't fix, as designed" or whatever, but point 2 does seem like a bug. |
It's not clear in the documentation but default is supposed to not cascade from my reading. What were the constraints set to before? |
Before the FKs were set to So it seems the cascading delete on the owning side didn't change, just the cascading update. On the other side the cascading delete changed, and the the cascading update did not. |
Seems related #5714 With that in mind this makes sense as the expected behavior. |
Issue Description
When upgrading from an older version of TypeORM I noticed my schema was no longer in sync. I isolated the breaking change to version 0.2.33 (0.2.34 is current).
Previously, the FKs on the join table were all set to
ON DELETE CASCADE
by default (andON UPDATE NO ACTION
).Expected Behavior
When I run
typeorm schema:log
I should see:Actual Behavior
After upgrading
typeorm schema:log
outputs:Steps to Reproduce
typeorm schema:log
.Here's the relevant snippet from my entity:
I'm not sure if it's important that my entity be self-referential or not. In my case an Invoice may have many child invoices, and an invoice may also have many parent invoices.
My Environment
Additional Context
I was able to work around the issue by changing my entity to explicitly set the cascading behavior of the foreign keys:
Relevant Database Driver(s)
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?
Since I have a workaround this isn't too pressing for me, so I don't intend to investigate further or open a pull request. Though if I knew more about TypeORM internals I probably would. It also occurred to me that, since this isn't the expected behavior with other foreign keys, just for join tables, this might be the expected behavior anyway and that the previous behavior was incorrect.
The text was updated successfully, but these errors were encountered: