rake db:test:clone fails due to test:purge being redefined

17 views
Skip to first unread message

Anton Jenkins

unread,
Jun 24, 2009, 3:34:34 PM6/24/09
to Oracle enhanced adapter for ActiveRecord
Hiya

I'm currently trying to set some tests up on a rails project which
uses oracle_enhanced to connect to an additional oracle database (so
the development, test and production databases are non oracle). I'm
using a sqlite3 database for test but when I run db:test:clone --trace
I get the following output :

** Invoke db:test:clone (first_time)
** Invoke db:schema:dump (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:schema:dump
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
rake aborted!
undefined method `structure_drop' for
#<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x2276df0>
/opt/local/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-
adapter-1.2.0/lib/active_record/connection_adapters/
oracle_enhanced.rake:38
<snip>

I've tracked this down to oracle_enhanced.rake redefining two tasks in
the db:test namespace - clone_structure and purge. If I comment out
the contents of this rake file then I can perform db:test:clone with
no problems.

Could this be because oracle_enhanced is assuming I'm using an oracle
database for test and is calling structure_drop which is only present
in the oracle_enhanced adapter? Would it be possible for the rake task
to check the class of the connection and only try calling this method
if it finds an oracle_enhanced connection?

Cheers

Anton

an...@pixellatedvisions.com

unread,
Jun 24, 2009, 4:27:55 PM6/24/09
to Oracle enhanced adapter for ActiveRecord
I've got it working for me by editing oracle_enhanced_tasks.rb and
specifying that the adapter for the current environment must be
oracle_enhanced, otherwise don't load the oracle_enhanced rake
tasks....

# RSI: implementation idea taken from JDBC adapter
if defined?(Rake.application) && Rake.application &&
ActiveRecord::Base.configurations[RAILS_ENV]['adapter'] ==
'oracle_enhanced'
oracle_enhanced_rakefile = File.dirname(__FILE__) + "/
oracle_enhanced.rake"
if Rake.application.lookup("environment")
# rails tasks already defined; load the override tasks now
load oracle_enhanced_rakefile
else
# rails tasks not loaded yet; load as an import
Rake.application.add_import(oracle_enhanced_rakefile)
end
end

I don't know if this breaks anything else?

Anton

Raimonds Simanovskis

unread,
Jun 25, 2009, 11:17:01 AM6/25/09
to Oracle enhanced adapter for ActiveRecord
This seems like a good solution for cases when oracle_enhanced is not
used for development/test environments.
Will add this change to next version of adapter.

Raimonds

On Jun 24, 11:27 pm, "an...@pixellatedvisions.com"

an...@pixellatedvisions.com

unread,
Jun 26, 2009, 4:48:01 AM6/26/09
to Oracle enhanced adapter for ActiveRecord
Good stuff. I've forked the project on github and applied the fix
(along with a pull request) :

http://github.com/antonjenkins/oracle-enhanced/commit/01b016cafb9e18486724a04a999e63afd91ea814

Cheers

Anton

On Jun 25, 4:17 pm, Raimonds Simanovskis
Reply all
Reply to author
Forward
0 new messages