transaction_retry icon indicating copy to clipboard operation
transaction_retry copied to clipboard

Bug with Ruby version 3.0 or above

Open nathanstitt opened this issue 2 years ago • 1 comments

Ruby 3 changed how hash arguments are handled in methods that use a splat for optional arguments.

This caused a bug with the overridden ActiveRecord::Base.transaction method because the original method has signature: def transaction(**options, &block) but the aliased method has def transaction_with_retry(*objects, &block)

https://github.com/rails/rails/blob/6-0-stable/activerecord/lib/active_record/transactions.rb#L211` https://github.com/qertoip/transaction_retry/blob/master/lib/transaction_retry/active_record/base.rb#L19

The error thrown appears as:

ArgumentError:
  wrong number of arguments (given 1, expected 0)
  # gems/3.0.0/gems/activerecord-6.1.7.6/lib/active_record/transactions.rb:208:in `transaction'

Since this library appears unmaintained, I've fixed the bug and forked for my teams use as openstax_transaction_retry here: https://github.com/openstax/transaction_retry The commit to fix was https://github.com/openstax/transaction_retry/commit/9184c88ab917271026e08d6dd5e890740f7fdd48

nathanstitt avatar Aug 28 '23 17:08 nathanstitt

I fixed it here: https://github.com/iagopiimenta/transaction_retry_continued

iagopiimenta avatar Jun 02 '24 18:06 iagopiimenta