Posts tagged ‘Oracle_enhanced driver’

I am working on rails application that talks to legacy oracle database. The id columns are named as oid and they are of number type. The emulate_integers_by_column_name attribute in oracle enhanced driver allows us to set this attribute to true, to change the type of id columns to fixnum. I wrote this code to override and work for columns with oid in its name. All you need to do is put it in a separate file in initializers directory and off you go it works.. :)

ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true

ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.instance_eval do
  def is_integer_column?(name)
      name =~ /(^|_)oid$/i
  end
end