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

Force-destroying nested, permanent records not possible with foreign keys? #66

Open
aried3r opened this issue Jan 29, 2016 · 5 comments

Comments

@aried3r
Copy link

aried3r commented Jan 29, 2016

It's a bit, but not quite related to #65.

I'm trying to delete a permanent record, which has_many permanent records using record.destroy(:force), but I get stuck because referential integrity is violated by doing this.

I took a look at the specs, which try to verify that this works, but (I think) SQLite does not enforce referential integrity the way PostgreSQL does.

In the code I found this segment which seems to be the code at fault (should I be correct about my assumption).
The records in the has_many association are properly being saved in dependent_records, however, the block, in this case super() gets called before, meaning that before permanent_records has a chance to indeed delete the records that are permanent, my code crashes because super throws an exception before this can happen.

@aried3r
Copy link
Author

aried3r commented Jan 29, 2016

I just tested by swapping out this gem by acts_as_paranoid, it works with acts_as_paranoid, but I'd love to stick with this gem, because of the explicit scopes and the small codebase. :)

Edit: Also works with the paranoia gem.

@aried3r
Copy link
Author

aried3r commented Jan 29, 2016

If I understand this code correctly, they delete the associated records first, then the record itself within a transaction.

@drakmail
Copy link
Collaborator

Today I'm launched all specs with postgresql as DB and no specs failed. Seems that the issue requiring additional specs.

@danguyenedu
Copy link

@aried3r @drakmail did you find a solution for this?

@aried3r
Copy link
Author

aried3r commented Oct 5, 2016

@airpoli I have since switched to paranoia 2.2.0.pre.

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

No branches or pull requests

3 participants