diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-30 15:45:15 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-30 15:45:15 +0000 |
commit | eefe4d0ddd077f5e27caf8bfb5d306ed6cc86ed8 (patch) | |
tree | fb2f97b18b20d53c2a27e940c4692404cac885a8 /activerecord/lib/active_record | |
parent | 54f2d1d944bb7577ef33ab086191992210f4788c (diff) | |
download | rails-eefe4d0ddd077f5e27caf8bfb5d306ed6cc86ed8.tar.gz rails-eefe4d0ddd077f5e27caf8bfb5d306ed6cc86ed8.tar.bz2 rails-eefe4d0ddd077f5e27caf8bfb5d306ed6cc86ed8.zip |
Fixed extraneous comma in count() function that made it not work with joins #1156 [jarkko/Dee.Zsombor]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1262 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 8136e101f4..c11b6d23ed 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -438,9 +438,8 @@ module ActiveRecord #:nodoc: # Returns the number of records that meets the +conditions+. Zero is returned if no records match. Example: # Product.count "sales > 1" def count(conditions = nil, joins = nil) - tbl_var_name = joins ? table_name[0,1].downcase : "" - sql = "SELECT COUNT(*) FROM #{table_name} #{tbl_var_name} " - sql << ", #{joins} " if joins + sql = "SELECT COUNT(*) FROM #{table_name} " + sql << " #{joins} " if joins add_conditions!(sql, conditions) count_by_sql(sql) end |