# Fix oracle\_adapter to pass test\_assign\_ids IN associations\_test.rb

**URL:** <https://www.ruby-forum.com/t/fix-oracle-adapter-to-pass-test-assign-ids-in-associations-test-rb/132322>\
**Category:** Ruby\
**Created:** [March 19, 2008, 5:32am UTC](https://www.ruby-forum.com/t/fix-oracle-adapter-to-pass-test-assign-ids-in-associations-test-rb/132322 "2008-03-19T05:32:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidtar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/54ee81/32.png) [@davidtar](https://www.ruby-forum.com/u/davidtar)\
**Post date:** [March 19, 2008, 5:32am UTC](https://www.ruby-forum.com/t/fix-oracle-adapter-to-pass-test-assign-ids-in-associations-test-rb/132322/1 "2008-03-19T05:32:34Z")

</div>

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?
