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

Fix #206 - Overtaking events are deleted now, when the parent track is deleted #246

Merged
merged 1 commit into from May 21, 2022

Conversation

boldt
Copy link
Contributor

@boldt boldt commented May 21, 2022

Summary

This fixes #206. When I delete a track, the event points on the public map are deleted as well.

@gluap @opatut I dont know how to add migrations. Please support. Thanks.

Solution

This sounds exaclty like our problem:

I cannot get a simple cascade delete to operate correctly -- if a parent element is a deleted, the children persist, with null foreign keys

That thread also provides a solution:

Setting the passive_deletes=True prevents SqlAlchemy from NULLing out the foreign keys.

This is, what is MR does: It adds passive_deletes=True to the relationships.

See:

@sonarcloud
Copy link

sonarcloud bot commented May 21, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell D 6 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@gluap
Copy link
Contributor

gluap commented May 21, 2022

@boldt this one shouldn't need a migration, the relationship shouldn't change the schema. If I understand this correctly the default behavior of sqlalchemy applied to our situation is to null the foreignkey in the overtaking_event table before deleting the track from the track table. As the reference isn't there when the track is deleted, nothing propagated. This also explains why deleting a track via command line didn't reproduce the issue.

@gluap gluap merged commit f70f4d5 into main May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deleting track doesn't delete overtaking_event, delete cascade doesn't work, data stays being visible
2 participants