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

Rails 6 issues with only_deleted with_deleted scopes #205

Open
unlimit opened this issue Mar 2, 2021 · 4 comments
Open

Rails 6 issues with only_deleted with_deleted scopes #205

unlimit opened this issue Mar 2, 2021 · 4 comments

Comments

@unlimit
Copy link

unlimit commented Mar 2, 2021

Hi!
We recently switched our app to Rails 6(6.1.2) and we noticed that only_deleted and with_deleted scopes doesn't work properly via associations

class User < ApplicationRecord
  acts_as_paranoid
  belongs_to :company
end

class Company < ApplicationRecord
  acts_as_paranoid
  has_many :users
end

c = Company.find 1
c.users.only_deleted.count

generates sql:
SELECT COUNT() FROM "users" WHERE "users"."deleted_at" IS NOT NULL
expecting sql:
SELECT COUNT(
) FROM "users" WHERE "users"."company_id" = $1 AND "users"."deleted_at" IS NOT NULL

@mvz mvz added the bug label Mar 2, 2021
@jprince
Copy link

jprince commented Jun 4, 2021

@unlimit I know this is a few months old, but I was experiencing a similar issue and upgrading to v0.7.3 resolved it.

@mvz
Copy link
Contributor

mvz commented Jun 5, 2021

@unlimit can you confirm that acts_as_paranoid 0.7.3 resolves your problem?

@jshah
Copy link

jshah commented Nov 11, 2021

I was getting NoMethodError: undefined method equality?' when using only_deleted and upgrading to v0.7.3 fixed it for me.

@mvz
Copy link
Contributor

mvz commented Nov 12, 2021

@jshah how is that related to the original bug report?

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

No branches or pull requests

4 participants