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

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

This commit is contained in:
Szymon Nowak 2013-10-14 19:51:29 +02:00
parent db82e1d0bb
commit 4ba9c508ec
2 changed files with 5 additions and 2 deletions

View file

@ -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*

View file

@ -244,8 +244,7 @@ module ActiveRecord
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.