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

wrong number of arguments error with Ruby 3 #276

Closed
ankane opened this issue Dec 28, 2020 · 3 comments
Closed

wrong number of arguments error with Ruby 3 #276

ankane opened this issue Dec 28, 2020 · 3 comments

Comments

@ankane
Copy link
Contributor

ankane commented Dec 28, 2020

Hi, was testing out distribute_reads with Ruby 3, and it looks like there are some errors related to the keyword arguments changes. Here's a script to reproduce:

require "active_record"
require "makara"

ActiveRecord::Base.establish_connection(
  adapter: "postgresql_makara",
  makara: {
    sticky: true,
    connections: [
      {
        role: "master",
        name: "primary",
        database: "distribute_reads_test_primary"
      },
      {
        name: "replica",
        database: "distribute_reads_test_replica"
      }
    ]
  }
)

ActiveRecord::Migration.create_table :users, force: true do |t|
  t.string :name
end

And the stack trace:

/Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.0/lib/active_record/connection_adapters/abstract/schema_statements.rb:296:in `create_table': wrong number of arguments (given 2, expected 1) (ArgumentError)
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/makara-0.4.1/lib/makara/connection_wrapper.rb:99:in `public_send'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/makara-0.4.1/lib/makara/connection_wrapper.rb:99:in `method_missing'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/makara-0.4.1/lib/makara/proxy.rb:105:in `public_send'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/makara-0.4.1/lib/makara/proxy.rb:105:in `block in method_missing'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/makara-0.4.1/lib/makara/proxy.rb:152:in `block in any_connection'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/makara-0.4.1/lib/makara/pool.rb:100:in `block in provide'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/makara-0.4.1/lib/active_record/connection_adapters/makara_abstract_adapter.rb:38:in `handle'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/makara-0.4.1/lib/makara/pool.rb:99:in `provide'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/makara-0.4.1/lib/makara/proxy.rb:151:in `any_connection'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/makara-0.4.1/lib/makara/proxy.rb:103:in `method_missing'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:929:in `block in method_missing'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:897:in `block in say_with_time'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/3.0.0/benchmark.rb:293:in `measure'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:897:in `say_with_time'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:918:in `method_missing'
  from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:658:in `method_missing'
@andrewkendall
Copy link

I'm also seeing the same issue when using Ruby 3.0.0.

@mlarraz
Copy link
Member

mlarraz commented Jan 19, 2021

Fixed in #283

@mlarraz mlarraz closed this as completed Jan 19, 2021
@ankane
Copy link
Contributor Author

ankane commented Jan 19, 2021

Thanks @mlarraz, works great!

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

3 participants