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:
parent
bdf59a5618
commit
8734f9a271
2 changed files with 7 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue