diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 1 | ||||
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 48a7d15ea8..a0e1420055 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -459,6 +459,7 @@ module ActiveRecord end if result.size == expected_size + return result if self.values[:order] records_by_id = result.index_by(&:id) ids.first(expected_size).collect { |id| records_by_id[id.to_i] } else diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 3ea1299b1c..1ab91c5195 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -76,6 +76,11 @@ class FinderTest < ActiveRecord::TestCase assert_equal 'The Third Topic of the day', records[0].title assert_equal 'The First Topic', records[1].title assert_equal 'The Fifth Topic of the day', records[2].title + + records = Topic.order(:id).find([5,3,1]) + assert_equal 'The First Topic', records[0].title + assert_equal 'The Third Topic of the day', records[1].title + assert_equal 'The Fifth Topic of the day', records[2].title end def test_find_with_ids_and_limit |