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: unable to delete objects with comments #702

Merged
merged 2 commits into from
Oct 26, 2022

Conversation

psrok1
Copy link
Member

@psrok1 psrok1 commented Oct 26, 2022

Your checklist for this pull request

  • I've read the contributing guideline.
  • I've tested my changes by building and running the project, and testing changed functionality (if applicable)
  • I've added automated tests for my change (if applicable, optional)
  • I've updated documentation to reflect my change (if applicable)

What is the current behaviour?

We're unable to delete object with comments.

What is the new behaviour?

Problem was caused by two relationships between Object and Comment table that were trying to reconcilate the fact that Object is deleted:

  • comments with cascade="delete" included that deletes all comments that are orphaned
  • comment_authors with default cascade setting that expects comments to be not deleted because they're treated like secondary table representing many-to-many relationship between objects and users.

These actions are in conflict that can be solved using passive_deletes=True, because foreign key constraints have already set ondelete behavior.

In addition, I set passive_deletes on comments as well to make sqlalchemy not even bother about that relationship (ondelete does the job passively from the SQLAlchemy perspective)

I don't know why it never happened before, maybe bug was somehow exposed by flattening the object inheritance model in 2.8.0.

Test plan

Closing issues

closes #697

@psrok1 psrok1 marked this pull request as ready for review October 26, 2022 15:41
@psrok1 psrok1 force-pushed the fix/delete-object-with-comments branch from f2e8c97 to 9404ec5 Compare October 26, 2022 17:37
@psrok1 psrok1 merged commit eefd7e2 into master Oct 26, 2022
@psrok1 psrok1 deleted the fix/delete-object-with-comments branch October 26, 2022 19:15
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.

Unable to delete sample
1 participant