Permalink
Browse files

In Relation#empty? use #exists? instead of #count.

  • Loading branch information...
1 parent db82e1d commit 4ba9c508ec1d59dd43154022479a37558f8c19f3 @szimek szimek committed Oct 14, 2013
Showing with 5 additions and 2 deletions.
  1. +4 −0 activerecord/CHANGELOG.md
  2. +1 −2 activerecord/lib/active_record/relation.rb
@@ -1,3 +1,7 @@
+* Make `Relation#empty?` use `exists?` instead of `count`.
+
+ *Szymon Nowak*
+
* `rake db:structure:dump` no longer crashes when the port was specified as `Fixnum`.
*Kenta Okamoto*
@@ -244,8 +244,7 @@ def size
def empty?
return @records.empty? if loaded?
- c = count(:all)
- c.respond_to?(:zero?) ? c.zero? : c.empty?
+ limit_value == 0 ? true : !exists?
end
# Returns true if there are any records.

0 comments on commit 4ba9c50

Please sign in to comment.