Closed VitaliSakolski closed 10 months ago
I have an issue related to this. In my case, for example record.destroy
returns false, but the deleted_at
column is updated.
Thanks for reporting it. I don't know what would be causing it... 7.0.6 diff is pretty thin from 7.0.5
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
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
can you try this https://github.com/rubysherpas/paranoia/pull/545 and let us know ?
can you try this #545 and let us know ?
Ok, will let you know about results
UPD: Nope, does not work :(
can you try this #545 and let us know ?
Just tried this solution - still doesn't work
(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 ?
what is wrong ?
Where am I wrong?
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.
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
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: