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

delete_all does real deletion #70

Open
talexu opened this issue Feb 16, 2017 · 2 comments
Open

delete_all does real deletion #70

talexu opened this issue Feb 16, 2017 · 2 comments

Comments

@talexu
Copy link

talexu commented Feb 16, 2017

Hi, I have an issue about delete_all in transaction.
Here is a piece of my code

MyModel.transaction do
   MyModel.delete_all(region: 'xxx')
   ...
end

And I found that it generates a SQL of

DELETE
FROM `my_models`
WHERE `my_models`.`deleted_at` IS NULL AND `my_models`.`region` = 'xxx'

The expectation should be

UPDATE `my_models`
WHERE `my_models`.`deleted_at` IS NULL AND `my_models`.`region` = 'xxx'
SET `my_models`.`deleted_at` = Now

Is this a bug or is there any issue in my code?
Thanks.

@tmlee
Copy link

tmlee commented Mar 1, 2017

@talexu I am not experiencing that when it is wrapped in a Transaction.
Any other parts of your code that you can show which may be helpful?
How about just calling delete on a single instance?

@tsujigiri
Copy link

tsujigiri commented Nov 2, 2017

I'm seeing the same when I add the composite_primary_keys gem to our project, even if I don't use it.

versions:
composite_primary_keys: 9.0.8
acts_as_paranoid: 0.5.0

EDIT: I found a workaround for my case. When I put acts_as_paranoid after composite_primary_keys in the Gemfile, it works. Presumably because it changes the load order of the gems. 😄

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