-
Notifications
You must be signed in to change notification settings - Fork 528
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
paranoia delete
throws exception when wrapped in a database cleaner transaction when running specs via rspec
#274
Comments
Hi @ipd! What steps can I follow to reproduce this within a new app? |
I'll see what i can come up with. |
@ipd Any progress? |
Sorry @krainboltgreene @radar I haven't had time to reproduce it. I was planning on making a new rails project and reproducing it there. I'll try to get to it today or tomorrow and will post a link to the repo with the rails project when i do. |
No worries, if I don't hear back from you I'll give it a shot this weekend.
|
I'm using MiniTest -- I resolved this error by using the transaction strategy and stating my before and after actions like so: DatabaseCleaner.strategy = :transaction
class MiniTest::Spec
before :each do
DatabaseCleaner.start
end
after :each do
DatabaseCleaner.clean
end
end |
I'm getting this issue while running a Rake task in production using Rails 4.2.5. I've tried wrapping the execution of the delete statement with an explicit transaction. Nada. Same error as described. :( |
I came across this error while deleting a record and I have added a custom column(archived_at) instead of default(deleted_at). class Room < ActiveRecord::Base
acts_as_paranoid column: :archived_at
end With
Without class Room < ActiveRecord::Base
# acts_as_paranoid column: :archived_at
end
Something in paranoia is causing issue. Trying to figure-out whats going wrong. |
In the console it fails because it expects to be executed in a transaction, try this instead:
|
Okay. Yes it worked but I actually wanted to permanently delete a record.
|
Fixes rubysherpas#274 It looks like ActiveRecord refactored the Transaction class hierarchy in a non-backwards-compatible way (rails/rails#16363), which breaks `add_to_transaction` for null transactions (I think it probably qualifies as a bug). The workaround is to not try to use `add_to_transaction` in null transactions.
…llTransaction errors Patches Paranoia gem to fix a conflict with transactions in Rspec: rubysherpas/paranoia#274 Example error: ``` Failure/Error: order.line_items.first.variant.tap(&:delete) NoMethodError: undefined method `state' for #<ActiveRecord::ConnectionAdapters::NullTransaction:0x0000564117dddd18> ```
…llTransaction errors Patches Paranoia gem to fix a conflict with transactions in Rspec: rubysherpas/paranoia#274 Example error: ``` Failure/Error: order.line_items.first.variant.tap(&:delete) NoMethodError: undefined method `state' for #<ActiveRecord::ConnectionAdapters::NullTransaction:0x0000564117dddd18> ```
…llTransaction errors Patches Paranoia gem to fix a conflict with transactions in Rspec: rubysherpas/paranoia#274 Example error: ``` Failure/Error: order.line_items.first.variant.tap(&:delete) NoMethodError: undefined method `state' for #<ActiveRecord::ConnectionAdapters::NullTransaction:0x0000564117dddd18> ```
…llTransaction errors Patches Paranoia gem to fix a conflict with transactions in Rspec: rubysherpas/paranoia#274 Example error: ``` Failure/Error: order.line_items.first.variant.tap(&:delete) NoMethodError: undefined method `state' for #<ActiveRecord::ConnectionAdapters::NullTransaction:0x0000564117dddd18> ```
…llTransaction errors Patches Paranoia gem to fix a conflict with transactions in Rspec: rubysherpas/paranoia#274 Example error: ``` Failure/Error: order.line_items.first.variant.tap(&:delete) NoMethodError: undefined method `state' for #<ActiveRecord::ConnectionAdapters::NullTransaction:0x0000564117dddd18> ```
…llTransaction errors Patches Paranoia gem to fix a conflict with transactions in Rspec: rubysherpas/paranoia#274 Example error: ``` Failure/Error: order.line_items.first.variant.tap(&:delete) NoMethodError: undefined method `state' for #<ActiveRecord::ConnectionAdapters::NullTransaction:0x0000564117dddd18> ```
…llTransaction errors Patches Paranoia gem to fix a conflict with transactions in Rspec: rubysherpas/paranoia#274 Example error: ``` Failure/Error: order.line_items.first.variant.tap(&:delete) NoMethodError: undefined method `state' for #<ActiveRecord::ConnectionAdapters::NullTransaction:0x0000564117dddd18> ```
…llTransaction errors Patches Paranoia gem to fix a conflict with transactions in Rspec: rubysherpas/paranoia#274 Example error: ``` Failure/Error: order.line_items.first.variant.tap(&:delete) NoMethodError: undefined method `state' for #<ActiveRecord::ConnectionAdapters::NullTransaction:0x0000564117dddd18> ```
…llTransaction errors Patches Paranoia gem to fix a conflict with transactions in Rspec: rubysherpas/paranoia#274 Example error: ``` Failure/Error: order.line_items.first.variant.tap(&:delete) NoMethodError: undefined method `state' for #<ActiveRecord::ConnectionAdapters::NullTransaction:0x0000564117dddd18> ```
This happens with v2.1.4 but not with v2.1.3. So it is caused by the changes introduced in the most recent release (v2.14). I discovered this after updating the gems in our Gemfile.
When running our specs using rspec and wrapping the specs using the DatabaseCleaner gem.
I think it is caused because Paranoia is calling
add_to_transaction
but the transaction is anActiveRecord::ConnectionAdapters::NullTransaction
which apparently does not respond tostate
.Here is the stack trace from one of my specs.
The text was updated successfully, but these errors were encountered: