diff options
author | Szymon Nowak <szimek@gmail.com> | 2013-10-14 19:51:29 +0200 |
---|---|---|
committer | Szymon Nowak <szimek@gmail.com> | 2013-10-19 21:53:45 +0200 |
commit | 4ba9c508ec1d59dd43154022479a37558f8c19f3 (patch) | |
tree | 5998a224b53e59df9d42900a7fe9fdbd17bfe376 | |
parent | db82e1d0bb21c2a13354b97733c09737719e946b (diff) | |
download | rails-4ba9c508ec1d59dd43154022479a37558f8c19f3.tar.gz rails-4ba9c508ec1d59dd43154022479a37558f8c19f3.tar.bz2 rails-4ba9c508ec1d59dd43154022479a37558f8c19f3.zip |
In Relation#empty? use #exists? instead of #count.
-rw-r--r-- | activerecord/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 815e7c71fe..22a37810bc 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -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* diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index cfaf566ec4..81548117b0 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -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. |