Closed pauldruziak closed 3 months ago
Hi @pauldruziak I tried the test you posted in this issue and can confirm that it fails with Rails 6.1, 7.0 and 7.1.
Which version of acts_as_paranoid
are you using in your project?
@mvz I use v0.7.3. The problem is in the next lines:
paranoid_where_clause = ActiveRecord::Relation::WhereClause.new([paranoid_default_scope])
scope.where_clause = all.where_clause - paranoid_where_clause
The last line returns "paranoid_many_many_children"."deleted_at" IS NULL
to the query because of all.where_clause
@pauldruziak then it makes sense that your tests in #336 failed: The current release is 0.10.0.
Can you confirm that version 0.10.0 also does the wrong thing in your project, both for Rails 6.1 and 7.0?
@mvz yes, v0.10.0 doesn't work well for me in 6.1 and 7.0
Here is the test for the context, it passes in v0.7.3, but not in newer versions:
it "should work with has_many through" do
post = Post.create! name: "foo"
tag = post.tags.create! name: "bar"
tag.destroy
post.reload
expect(post.tags).to eq([])
expect(post.tags.with_deleted).to eq([tag])
end
it "should work with has_many through" do
post = Post.create! name: "foo"
tag = post.tags.create! name: "bar"
post.taggings.first.destroy
post.reload
expect(post.tags).to eq([])
expect(post.tags.with_deleted).to eq([tag])
end
Thanks for confirming that @pauldruziak.
@pauldruziak this should be fixed in version 0.10.1 which I just released.
@mvz thanks, it works 🎉
I added tests here to confirm it, but it failed in all versions: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/336
So, then I wrote this test in my project and it failed in 7.0 and passed in 6.1:
The only difference that I see right now is that
acts_as_paraniod
usesSQLite
for tests, while my project usesPostgreSQL
. I'm going to continue the investigation. And next step I see is creating a new Rails project withSQLite
to see how this will behave there.