jruby / activerecord-jdbc-adapter

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

undefined method `database_product' for nil:NilClass #1163

Open tykonu opened 10 hours ago

tykonu commented 10 hours ago

Hey!

Testing out jruby on an existing MRI app (postgresql).

jruby 9.4.9.0 (3.1.4) 2024-11-04 547c6b150e OpenJDK 64-Bit Server VM 17.0.2+8 on 17.0.2+8 +jit [x86_64-darwin]

Localhost launches fine, but when opening it in the browser it seems that something is going wrong with the DB connection:

NoMethodError (undefined method `database_product' for nil:NilClass):

activerecord-jdbc-adapter-70.2 (java) lib/arjdbc/postgresql/adapter.rb:56:in redshift?' activerecord-jdbc-adapter-70.2 (java) lib/arjdbc/postgresql/adapter.rb:509:inclient_min_messages=' activerecord-jdbc-adapter-70.2 (java) lib/arjdbc/postgresql/adapter.rb:76:in configure_connection' arjdbc/jdbc/RubyJdbcConnection.java:596:inconfigure_connection' activerecord-jdbc-adapter-70.2 (java) lib/arjdbc/abstract/core.rb:25:in initialize' activerecord-jdbc-adapter-70.2 (java) lib/arjdbc/abstract/statement_cache.rb:23:ininitialize' activerecord-jdbc-adapter-70.2 (java) lib/arjdbc/postgresql/adapter.rb:769:in initialize' org/jruby/RubyClass.java:949:innew'

Extracted source around line #56:

  if ( redshift = config[:redshift] ).nil?        
        redshift = !! (@connection.database_product || '').index('Redshift')       
  end
  redshift

end

Standard database.yml, works well on MRI.

headius commented 3 hours ago

Thanks for the report! Is your Rails app also Rails 7.0? The latest ARJDBC adapters currently released are for 7.0 and probably won't work on a Rails 7.1 or higher app.