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

reload_log_data doesn't work when used with acts_as_paranoid and deleted records #237

Open
matgaw opened this issue Apr 13, 2023 · 2 comments

Comments

@matgaw
Copy link

matgaw commented Apr 13, 2023

Tell us about your environment

**Ruby Version:3.0.5

**Rails Version:7.0.4

**PostgreSQL Version:13.9

**Logidze Version:1.2.3

What did you do?

Using logidze and acts_as_paranoid in one project. When record is marked as deleted with acts_as_paranoid, and I load it like so:

obj = SomeObject.with_deleted.find(some_id)

and then execute:

obj.reload_log_data

What did you expect to happen?

log_data gets loaded

What actually happened?

The query is affected by acts_as_paranoid and adds WHERE "some_objects"."deleted_at" IS NULL - resulting in log_data being null.

Not sure how to work-around it, or which gem should actually fix it.

@matgaw
Copy link
Author

matgaw commented Apr 13, 2023

Actually I think this should be reported to acts_as_paranoid gem

@matgaw matgaw closed this as completed Apr 13, 2023
@palkan
Copy link
Owner

palkan commented Apr 13, 2023

I think, you posted issue in the right place.

We do not take scopes into account when reloading the log data:

self.log_data = self.class.where(self.class.primary_key => id).pluck("#{self.class.table_name}.log_data".to_sym).first

Adding .unscoped here makes senses. Or, probably, add an option to reload without taking default scopes into account: record.reload_log_date(unscoped: true)

@palkan palkan reopened this Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants