ray_apps_blog

February 24, 2010

ActiveRecord Oracle enhanced adapter version 1.2.4

Filed under: oracle,oracle-enhanced,rails,ruby — Raimonds Simanovskis @ 3:23 pm

I have released maintenance version of ActiveRecrod Oracle enhanced adapter with some bug fixes and some new features. This is the last maintenance version for Rails 2, I have already done majority of work to support also Rails 3 in next adapter versions, but that deserves another post when it will be ready :).

Detailed changes can be found in change history file and commit log, here I will point out the main changes.

Schema and structure dump

There are several improvements in schema (rake db:schema:dump) and structure dump (rake db:structure:dump) tasks. Now structure dump is improved to contain all schema objects in SQL statements format.

Also db:test:purge rake task (which is run before recreating test schema when running rake test or rake spec) is changed that it will delete all schema objects from test schema – including also views, packages, procedures and functions which are not recreated from schema.rb. So if you need to have additional database objects in your schema besides tables, indexes, sequences and synonyms (which are dumped in schema.rb) then you need to recreate them after standard rake task db:schema:load is run. Here is example how to execute any additional tasks after db:schema:load (include this in some .rake file in lib/tasks directory):

namespace :db do
  namespace :schema do
    task :load do
      Rake::Task["db:schema:create_other_objects"].invoke
    end
    task :create_other_objects do
      # include code here which creates necessary views, packages etc.
    end
  end
end

Additional options for schema definition methods

You can pass :temporary => true option for create_table method to create temporary tables.

You can use :tablespace => “tablespace name” option for add_index method to create index in non-default Oracle tablespace that is specified for user (e.g. if it is requested by your DBA for performance reasons). You can also define function based indexes using add_index and they will be correctly dumped in schema.rb.

Savepoints and nested ActiveRecord transactions

oracle_enhanced adapter now supports ActiveRecord nested transactions using database savepoints.

ruby-oci8 version

As I am using and testing oracle_enhanced adapter just with ruby-oci8 2.0.3 then I have made this as precondition (if you use MRI 1.8 or 1.9). So if you haven’t yet upgraded to latest ruby-oci8 version then please do so before upgrading to oracle_enhanced 1.2.4.

JNDI connection support

If you are using oracle_enhanced with JRuby then now you can also use JNDI database connections – please see this issue with comments to see some examples.

Install

As always you can install Oracle enhanced adapter on any Ruby platform (Ruby 1.8.6 / 1.8.7 or Ruby 1.9.1 or JRuby) with

gem install activerecord-oracle_enhanced-adapter

If you have any questions please use discussion group or post comments here.

Advertisements

5 Comments

  1. Great – JNDI! Thanks a lot mate, thats really great news!

    Comment by Reto Schüttel — February 24, 2010 @ 8:04 pm

  2. Yesterday I found that the default oracle adapter doesn’t work fine when I try uploading files, but I installed the enhanced and worked.

    I have some jruby applications and will try use JNDI.

    Thaaanks!

    Comment by Lucas de Castro — February 25, 2010 @ 4:12 pm

  3. JNDI data source connection!!! Really great mews!

    Great many thanks for that!

    Comment by Renato — February 26, 2010 @ 7:24 pm

  4. I have a project use RoR and Oracle db, query very slowly if use Activerecord.But if use find_by_sql insead of use Activerecord, the query speed is shortten from 6-7s to 0.2s.I think that the issue is Activerecord compatible with oracle database, when Activerecord loaded the query seems really slow.I change current adapter to ‘oracle-enhanced’, but it seems that it didn’t improve anything.

    Do you have any better way to help me.
    Thank you very much.

    Comment by Dave — May 20, 2010 @ 9:00 am

    • Please post the details what exact queries you did on what tables and on what database at http://groups.google.com/group/oracle-enhanced and then probably someone can give some suggestions.

      Currently your problem description sounds like “My car won’t start. Typically I could start my car in couple seconds but now I cannot do it even in 10 seconds. What should I do?” :)

      Comment by Raimonds Simanovskis — May 20, 2010 @ 10:55 pm


RSS feed for comments on this post.

Blog at WordPress.com.

%d bloggers like this: