diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-25 21:56:21 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-25 21:56:21 +0000 |
commit | 109926c5a3472dd08b921b7729c0457ad23dcbf8 (patch) | |
tree | 0f12c096ffec1f15d232007e554bf52f43512a48 /activerecord/lib/active_record | |
parent | ad4f1fd630dbeeb66b9cde0979518b4af96201ad (diff) | |
download | rails-109926c5a3472dd08b921b7729c0457ad23dcbf8.tar.gz rails-109926c5a3472dd08b921b7729c0457ad23dcbf8.tar.bz2 rails-109926c5a3472dd08b921b7729c0457ad23dcbf8.zip |
Find with a list of ids supports limit/offset. Closes #8437.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6845 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 608651cd0a..81b492e65e 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1117,10 +1117,21 @@ module ActiveRecord #:nodoc: result = find_every(options) - if result.size == ids.size + # If the user passes in a limit to find(), we need to check + # to see if the result is limited before just checking the + # size of the results. + expected_size = + if options[:limit] && ids.size > options[:limit] + options[:limit] + else + ids.size + end + expected_size -= options[:offset] if options[:offset] + + if result.size == expected_size result else - raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions}" + raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions} (found #{result.size} results, but was looking for #{expected_size})" end end |