Fix oracle_adapter to pass test_assign_ids IN associations_test.rb

The oracle_adapter can fail test_assign_ids IN associations_test.rb if
the records within the projects table were not created in ID order.
eg if the record with the ID of 2 was created before the record with
ID of 1.

This is because Oracle returns result sets without an ORDER BY clause
in what they term Native order, this is unlike databases like MySql
which sorts by the first column.

The follow code would fix the problem, though I am not sure if it is
the correct way of writing the fix.

module ActiveRecord
class Base
class << self # Class methods
def find_some_with_patch(ids, options)
options[:order] ||=
“#{quoted_table_name}.#{connection.quote_column_name(primary_key)}”
find_some_without_patch(ids, options)
end
alias_method_chain :find_some, :patch
end
end
end

Can anyone suggest a better way of overloading the self.find_some
method within the oracle_adapter, besides using an alias_method_chain?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs