1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Relation#many? shoud load the records if there's a LIMIT

This commit is contained in:
Pratik Naik 2009-12-30 12:13:55 +05:30
parent bdf59a5618
commit 8734f9a271
2 changed files with 7 additions and 1 deletions

View file

@ -250,7 +250,7 @@ module ActiveRecord
if block_given?
to_a.many? { |*block_args| yield(*block_args) }
else
size > 1
@relation.send(:taken).present? ? to_a.many? : size > 1
end
end

View file

@ -471,4 +471,10 @@ class RelationTest < ActiveRecord::TestCase
assert posts.loaded?
end
def test_many_with_limits
posts = Post.scoped
assert posts.many?
assert ! posts.limit(1).many?
end
end