Permalink
Browse files

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

  • Loading branch information...
1 parent bdf59a5 commit 8734f9a2710e6ad62caa7e1dcf543b83562e18ed @lifo lifo committed Dec 30, 2009
Showing with 7 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/relation.rb
  2. +6 −0 activerecord/test/cases/relations_test.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
@@ -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

0 comments on commit 8734f9a

Please sign in to comment.