Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 8734f9a2710e6ad62caa7e1dcf543b83562e18ed 1 parent bdf59a5
@lifo lifo authored
View
2  activerecord/lib/active_record/relation.rb
@@ -250,7 +250,7 @@ def many?
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
6 activerecord/test/cases/relations_test.rb
@@ -471,4 +471,10 @@ def test_many
assert posts.loaded?
end
+ def test_many_with_limits
+ posts = Post.scoped
+
+ assert posts.many?
+ assert ! posts.limit(1).many?
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.