diff options
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 73c69a91d1..03123758ef 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -464,13 +464,7 @@ module ActiveRecord #:nodoc: # Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id" def count_by_sql(sql) sql = sanitize_conditions(sql) - rows = connection.select_one(sql, "#{name} Count") - - if !rows.nil? and count = rows.values.first - count.to_i - else - 0 - end + connection.select_value(sql, "#{name} Count").to_i end # Increments the specified counter by one. So <tt>DiscussionBoard.increment_counter("post_count", |