active_record_mysql_xverify icon indicating copy to clipboard operation
active_record_mysql_xverify copied to clipboard

Adding double splat for Ruby 3.0 support

Open sikachu opened this issue 3 years ago • 1 comments

It seems like splat argument does not pass keyword argument as keyword argument, resulting in us getting ArgumentError:

ArgumentError: wrong number of arguments (given 3, expected 1..2)
$GEM_HOME/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:199:in `execute'
$GEM_HOME/active_record_mysql_xverify-0.2.2/lib/active_record_mysql_xverify/error_handler.rb:6:in `execute'
$GEM_HOME/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:207:in `execute_and_free'
$GEM_HOME/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:817:in `column_definitions'
$GEM_HOME/activerecord-7.0.2.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:116:in `columns'
$GEM_HOME/activerecord-7.0.2.3/lib/active_record/connection_adapters/schema_cache.rb:117:in `block in columns'
$GEM_HOME/activerecord-7.0.2.3/lib/active_record/connection_adapters/schema_cache.rb:116:in `fetch'

If you look at our caller, you can see that we're being called with two arguments and one keyword argument:

        yield execute(sql, name, async: async)

I believe that with a single *, this causes us to try to call the underlying execute method with sql, name, { async: async } as arguments.

Changing this to *, ** will prevent async keyword argument from turning into a Hash.

Note that once we drop Ruby 2.7 support we'll be able to change this method to just accept ... argument.

sikachu avatar Apr 21 '22 10:04 sikachu

I hope this Pull Request would be merged because our app also has this problem with Ruby 3.0, Rails 7.0, and MySQL.

r7kamura avatar Nov 14 '22 21:11 r7kamura

v3.0.0 has been released

winebarrel avatar Feb 25 '23 09:02 winebarrel