rsim/oracle-enhanced — Issue #108: undefined method `database_name' for #<ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter:0x45d1edcc>
Author: jospergon
Created: 2011-10-20 11:28:15+00:00
State: open

I'm using rails 2.3.5 and jruby 1.5.6, activerecord-jdbc-adapter 1.1.3 and activerecord-oracle_enhanced-adapter 1.3.2.

When I throw my battery of unit tests with rake test:units RAILS_ENV = test, i have this error:

** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
rake aborted!
undefined method `database_name' for #
/usr/local/rvm/gems/jruby-1.5.6@sica/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/jdbc.rake:70:in `find_database_name'
/usr/local/rvm/gems/jruby-1.5.6@sica/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/jdbc.rake:127
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `execute'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/usr/local/rvm/rubies/jruby-1.5.6/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:176:in `invoke_prerequisites'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:174:in `each'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:157:in `invoke_with_call_chain'
/usr/local/rvm/rubies/jruby-1.5.6/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/usr/local/rvm/gems/jruby-1.5.6@sica/gems/rails-2.3.5/lib/tasks/databases.rake:391
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `execute'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/usr/local/rvm/rubies/jruby-1.5.6/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:176:in `invoke_prerequisites'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:174:in `each'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:157:in `invoke_with_call_chain'
/usr/local/rvm/rubies/jruby-1.5.6/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/application.rb:90:in `top_level'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/application.rb:90:in `top_level'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/application.rb:62:in `run'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/bin/rake:32
/usr/local/rvm/gems/jruby-1.5.6@global/gems/rake-0.9.2/bin/rake:19:in `load'
/usr/local/rvm/rubies/jruby-1.5.6/bin/rake:19
Tasks: TOP => db:test:load => db:test:purge

I've solved it by adding the following code block to the file lib/active_record/connection_adapters/oracle_enhanced.rake, redefining the task db:test:load inside of the namespace :db do bock:

```ruby
redefine_task :load => :environment do |existing_actions|
abcs = ActiveRecord::Base.configurations
if abcs['test']['adapter'] =~ /oracle/i
ActiveRecord::Base.establish_connection(:test)
else
Array(existing_actions).each{|action| action.call}
end
end
```