Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

schema_plus 1.8.x: jruby + postgresql with activerecord-jdbcpostgresql-adpater > 1.3.14 #214

Open
ronen opened this issue Apr 15, 2015 · 2 comments

Comments

@ronen
Copy link
Member

ronen commented Apr 15, 2015

Something in activerecord-jdbcpostgresql-adapter changed in 1.3.15 or 1.3.16, causing this error when using schema_plus 1.8.x:

ArgumentError:
     wrong number of arguments calling `initialize` (7 for 4)
     # .../.gem/jruby/1.9.3/gems/activerecord-jdbc-adapter-1.3.16/lib/arjdbc/postgresql/adapter.rb:1164:in `columns'
    etc.

due to some sort of conflict caused when including schema_plus's Column module into ActiveRecord's.

I've temporarily removed jruby + postgresql from the build (commit 2a05925). But I'm not likely to have time to chase down the problem any time soon.

@donv, do you want to look into it?

@lfidnl
Copy link

lfidnl commented Jul 16, 2015

Hi!
I figured out this issue.
In activerecord-jdbc <= 1.3.12 initialize method was described in PostgreSQLColumn class.
But in activerecord-jdbc > 1.3.12 initialize method was moved to Arjdbc::ArJdbc::PostgreSQL module.

So, after including SchemaPlus::ConnectionAdapters::PostegreSQLColumn:
for <= 1.3.12 ActiveRecord::ConnectionAdapters::PostgreSQLColumn#initialize will be called from ActiveRecord::ConnectionAdapters::PostgreSQLColumn, because
ruby will search for #initialize method through all ancestors and will find it in ActiveRecord::ConnectionAdapters::PostgreSQLColumn class.

for > 1.3.12 ActiveRecord::ConnectionAdapters::PostgreSQLColumn#initialize will be called from SchemaPlus::ActiveRecord::ConnectionAdapters::PostgreSQLColumn, because
ruby will search for #initialize method through all ancestors and it won`t be able to find it in ActiveRecord::ConnectionAdapters::PostgreSQLColumn and will continue to search in
SchemaPlus::ConnectionAdapters::PostegreSQLColumn ancestor.
SchemaPlus::ConnectionAdapters::PostegreSQLColumn is the next ancestor because this extension was included in the last turn.

The solution is to include SchemaPlus::ActiveRecord::ConnectionAdapters::PostgreSQLColumn after Arjdbc::ArJdbc::PostgreSQL, but I can't understand how to do this.

@ronen
Copy link
Member Author

ronen commented Jul 24, 2015

@lfidnl thanks for tracking that down.

The solution is to include SchemaPlus::ActiveRecord::ConnectionAdapters::PostgreSQLColumn after Arjdbc::ArJdbc::PostgreSQL, but I can't understand how to do this.

Or maybe include SchemaPlus::ActiveRecord::ConnectionAdapters::PostgreSQLColumn into Arjdbc::ArJdbc::PostgreSQL::Column instead of into ActiveRecord::ConnectionAdapters::PostgreSQLColumn?

Unfortunately I'm not a jruby user, and don't have time to look into this myself; plus I'm mostly maintaining schema_plus 2.0 rather than 1.8 -- but I'm happy to accept a PR if you get it to work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants