diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-10-31 05:58:09 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-10-31 05:58:09 +0000 |
commit | 8f74527282680faacb68c3d88af7c2462b95365b (patch) | |
tree | 1740769cf0fae1c5a3813082eeec927daebe0f0a /activerecord/lib/active_record | |
parent | 3c9cd19786b1e74114d933594225f2fa37407be2 (diff) | |
download | rails-8f74527282680faacb68c3d88af7c2462b95365b.tar.gz rails-8f74527282680faacb68c3d88af7c2462b95365b.tar.bz2 rails-8f74527282680faacb68c3d88af7c2462b95365b.zip |
Escape table names during calculation queries. [wesley.moxam, Koz] Closes #4593
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8061 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/calculations.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb index 2327862f13..5ce31197d4 100644 --- a/activerecord/lib/active_record/calculations.rb +++ b/activerecord/lib/active_record/calculations.rb @@ -167,7 +167,7 @@ module ActiveRecord if operation == 'count' if merged_includes.any? options[:distinct] = true - column_name = options[:select] || [table_name, primary_key] * '.' + column_name = options[:select] || [connection.quote_table_name(table_name), primary_key] * '.' end if options[:distinct] @@ -182,7 +182,7 @@ module ActiveRecord sql << ", #{options[:group_field]} AS #{options[:group_alias]}" if options[:group] sql << " FROM (SELECT DISTINCT #{column_name}" if use_workaround - sql << " FROM #{table_name} " + sql << " FROM #{connection.quote_table_name(table_name)} " if merged_includes.any? join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(self, merged_includes, options[:joins], options[:ar_joins]) sql << join_dependency.join_associations.collect{|join| join.association_join }.join |