-
Notifications
You must be signed in to change notification settings - Fork 196
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
Paranoid join tables in through relationships do not work with with_deleted #337
Comments
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 |
@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 |
@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: #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.The text was updated successfully, but these errors were encountered: