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

destroy doesn't work with the new version of Rails 7.0.6 #544

Closed
VitaliSakolski opened this issue Jul 4, 2023 · 10 comments
Closed

destroy doesn't work with the new version of Rails 7.0.6 #544

VitaliSakolski opened this issue Jul 4, 2023 · 10 comments
Labels

Comments

@VitaliSakolski
Copy link

When I tried to upgrade to the latest version of Rails 7.0.6, the tests started crashing. What was my surprise when after investigating it turned out that destroy doesn't work. In fact, everything is in the screenshots below:

Screenshot at Jul 04 18-29-06 Screenshot at Jul 04 18-31-09 Screenshot at Jul 04 19-07-03
@dcrec1
Copy link

dcrec1 commented Jul 6, 2023

I have an issue related to this. In my case, for example record.destroy returns false, but the deleted_at column is updated.

@mathieujobin
Copy link
Collaborator

Thanks for reporting it. I don't know what would be causing it... 7.0.6 diff is pretty thin from 7.0.5

@Stashchenko
Copy link

Thanks for reporting it. I don't know what would be causing it... 7.0.6 diff is pretty thin from 7.0.5

The same issue on the rails 7.0.7

@mathieujobin
Copy link
Collaborator

I'm sorry, I am unable to come up with a patch at the moment, but if someone is willing to fix this and open a pull request, I can review and release.

Thanks

@mjobin-mdsol
Copy link

can you try this #545 and let us know ?

@Stashchenko
Copy link

Stashchenko commented Aug 28, 2023

can you try this #545 and let us know ?

Ok, will let you know about results

UPD: Nope, does not work :(

@VitaliSakolski
Copy link
Author

can you try this #545 and let us know ?

Just tried this solution - still doesn't work

@mathieujobin
Copy link
Collaborator

mathieujobin commented Aug 30, 2023

(byebug) subject
#<CostCenter id: 3, name: "Human Resources", account_id: 98, created_at: "2023-08-30 23:20:07.000000000 +0000", 
updated_at: "2023-08-30 23:20:07.000000000 +0000", deleted_at: nil>
(byebug) subject.destroy
#<CostCenter id: 3, name: "Human Resources", account_id: 98, created_at: "2023-08-30 23:20:07.000000000 +0000", 
updated_at: "2023-08-30 23:20:15.000000000 +0000", deleted_at: "2023-08-30 23:20:15.000000000 +0000">
(byebug) subject.reload
#<CostCenter id: 3, name: "Human Resources", account_id: 98, created_at: "2023-08-30 23:20:07.000000000 +0000", 
updated_at: "2023-08-30 23:20:15.000000000 +0000", deleted_at: "2023-08-30 23:20:15.000000000 +0000">

(byebug) CostCenter.where(id: 3)
#<ActiveRecord::Relation []>
(byebug) CostCenter.count 
2
(byebug) subject = CostCenter.where(id: 2).take 
#<CostCenter id: 2, name: "different name", account_id: 97, created_at: "2023-08-30 23:20:06.000000000 +0000", 
updated_at: "2023-08-30 23:20:06.000000000 +0000", deleted_at: nil>
(byebug) subject.destroy
#<CostCenter id: 2, name: "different name", account_id: 97, created_at: "2023-08-30 23:20:06.000000000 +0000", 
updated_at: "2023-08-30 23:21:35.000000000 +0000", deleted_at: "2023-08-30 23:21:35.000000000 +0000">
(byebug) CostCenter.count 
1
(byebug) CostCenter.find_by_sql('select * from cost_centers where deleted_at is not null')
[#<CostCenter id: 3, name: "Human Resources", account_id: 98, created_at: "2023-08-30 23:20:07.000000000 +0000", 

updated_at: "2023-08-30 23:20:15.000000000 +0000", deleted_at: "2023-08-30 23:20:15.000000000 +0000">, 
#<CostCenter id: 2, name: "different name", account_id: 97, created_at: "2023-08-30 23:20:06.000000000 +0000", 

updated_at: "2023-08-30 23:21:35.000000000 +0000", deleted_at: "2023-08-30 23:21:35.000000000 +0000">]
(byebug) 

what is wrong ?

@VitaliSakolski
Copy link
Author

VitaliSakolski commented Aug 31, 2023

what is wrong ?

Where am I wrong?

Gemfile:

Screenshot at Aug 31 10-58-55

Result:

Screenshot_at_Aug_31_10-49-33(1)

UPD:

Upon further investigation, the following issue was identified. Due to the specifics, we were using the before_destroy callback, which caused the above issue despite the patch. After replacing it with after_destroy everything started working as expected.

@mathieujobin
Copy link
Collaborator

mathieujobin commented Aug 31, 2023

I am also unsure what you use a fork version... Happy to hear you found the bug.

$ grep paranoia Gemfile*
Gemfile:gem 'paranoia'
Gemfile.lock:    paranoia (2.6.2)
Gemfile.lock:  paranoia

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

No branches or pull requests

5 participants