diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-31 17:15:56 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-31 17:15:56 +0000 |
commit | 8158455ded5811271e7d8530f262bc74a1677334 (patch) | |
tree | abeffb1a90c1d9aa5e086166ef9aa4893f4418a9 /activerecord/lib | |
parent | 0cf79f07b0be7bb9912dfe2a9f2f4c45d98ac41e (diff) | |
download | rails-8158455ded5811271e7d8530f262bc74a1677334.tar.gz rails-8158455ded5811271e7d8530f262bc74a1677334.tar.bz2 rails-8158455ded5811271e7d8530f262bc74a1677334.zip |
Fix an edge case with find with a list of ids, limit, and offset. Closes #8437.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6912 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 54f3a8252d..b838b1cdc0 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1032,16 +1032,18 @@ module ActiveRecord #:nodoc: result = find_every(options) - # 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. + # Determine expected size from limit and offset, not just ids.size. expected_size = if options[:limit] && ids.size > options[:limit] options[:limit] else ids.size end - expected_size -= options[:offset] if options[:offset] + + # 11 ids with limit 3, offset 9 should give 2 results. + if options[:offset] && (ids.size - options[:offset] < expected_size) + expected_size = ids.size - options[:offset] + end if result.size == expected_size result |