jruby / activerecord-jdbc-adapter

JRuby's ActiveRecord adapter using JDBC.
BSD 2-Clause "Simplified" License
462 stars 385 forks source link

`ArgumentError: wrong number of arguments (given 4, expected 1..3)` for `activerecord-jdbcsqlite3-adapter` #1136

Open AlexWayfer opened 1 year ago

AlexWayfer commented 1 year ago

I saw similar issues, but sqlite3 adapter seems to not be updated for years.

JRuby 9.4.3.0, ActiveRecord 7.0.7, activerecord-jdbcsqlite3-adapter 70.1.

ArgumentError: wrong number of arguments (given 4, expected 1..3)
                      initialize at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-70.1-java/lib/arjdbc/abstract/core.rb:12
                             new at org/jruby/RubyClass.java:931
                             new at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-70.1-java/lib/arjdbc/jdbc/callbacks.rb:14
                 jdbc_connection at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-70.1-java/lib/arjdbc/jdbc/connection_methods.rb:10
                     public_send at org/jruby/RubyKernel.java:2119
                  new_connection at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:656
         checkout_new_connection at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:700
  try_to_checkout_new_connection at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:679
              acquire_connection at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:640
                        checkout at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:341
                      connection at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:181
             retrieve_connection at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_handler.rb:211
             retrieve_connection at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-7.0.7.2/lib/active_record/connection_handling.rb:313
                      connection at /home/alex/.rbenv/versions/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-7.0.7.2/lib/active_record/connection_handling.rb:280
                          <main> at /home/alex/Projects/ruby/email_address/test/activerecord/user.rb:34
sampadha commented 10 months ago

Facing similar issue for mysql adapter : When can we expect activerecord-jdbcmysql-adapter to support rails 7.1?

JRuby 9.4.5.0, ActiveRecord 7.1.0, activerecord-jdbcmysql-adapter 70.1.

Uncaught exception: wrong number of arguments (given 4, expected 1..3)

/home/sam/Projects/SDKs/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-70.1-java/lib/arjdbc/abstract/core.rb:13:in `initialize' /home/sam/Projects/SDKs/jruby-9.4.3.0/lib/ruby/gems/shared/gems/userstamper-4.1.0/lib/userstamper/stampable.rb:22:in columns' /home/sam/Projects/SDKs/jruby-9.4.3.0/lib/ruby/gems/shared/gems/activerecord-7.1.1/lib/active_record/model_schema.rb:503:in column_names' /home/sam/Projects/SDKs/jruby-9.4.3.0/lib/ruby/gems/shared/gems/userstamper-4.1.0/lib/userstamper/utilities.rb:30:in available_association_columns' /home/sam/Projects/SDKs/jruby-9.4.3.0/lib/ruby/gems/shared/gems/userstamper-4.1.0/lib/userstamper/stampable.rb:69:in add_userstamp_associations' /home/sam/Projects/SDKs/jruby-9.4.3.0/lib/ruby/gems/shared/gems/userstamper-4.1.0/lib/userstamper/stampable.rb:39:in stampable' /home/sam/Projects/awetest/app/models/regression_test/job.rb:14:in class:Job' /home/sam/Projects/awetest/app/models/regression_test/job.rb:3:in

keithrbennett commented 3 months ago

A year later, I have the opposite problem. I get this error:

23:40:20 web.1  | ArgumentError (wrong number of arguments (given 1, expected 4)):
23:40:20 web.1  |
23:40:20 web.1  | activerecord-jdbc-adapter-70.2 (java) lib/arjdbc/sqlite3/adapter.rb:92:in `initialize'
23:40:20 web.1  | activerecord-jdbc-adapter-70.2 (java) lib/arjdbc/abstract/statement_cache.rb:23:in `initialize'
23:40:20 web.1  | org/jruby/RubyClass.java:922:in `new'
23:40:20 web.1  | activerecord (7.2.1) lib/active_record/database_configurations/database_config.rb:26:in `new_connection'

My Gemfile contains:

IS_JRUBY = (defined? JRUBY_VERSION)
if IS_JRUBY
  ruby '3.1.4'
  gem 'activerecord-jdbc-adapter'
  gem 'jdbc-sqlite3'
else
  ruby "3.3.4"
  gem 'sqlite3', '>= 2.0.4', '~> 2.0'
end

My Gemfile.lock contains:

activerecord (7.2.1)
activerecord-jdbc-adapter (70.2-java)
jdbc-sqlite3 (3.42.0.0)

UPDATE: I have reverted to using Postgres so I no longer need an answer, but I will leave this here for informational purposes.

enebo commented 2 months ago

@keithrbennett your problem is mostly due to the fact we do not support Rails 7.2. The thing we are not communicating well is that 70.x is Rails 7.0.x and when we support Rails 7.2 you will see a version 72.x come out for the adapters. It is good that postgresql is working but that is somewhat surprising since we have a lot of fixes coming in for 7.1 support. It is possible Rails 7.2 reverted something significant and the 70.x gems happen to work?

keithrbennett commented 2 months ago

@enebo Thanks for your reply. Sorry I didn't explain that clearly. It's not that Postgres works with Rails 7.2, it's just that I only tried to get it to work with Sqlite. This is a web site running on C Ruby in production, but I was hoping to make it JRuby compatible. I will defer that with Postgres until a future time.