diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-24 13:40:23 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-24 13:55:55 -0800 |
commit | cdf6cf01cb47bdcbc1e011c8f5f72b161f12bf9c (patch) | |
tree | 799f62fd5996189bc16dda689ecdc4d82f7c8496 /activerecord/lib/active_record/associations/class_methods | |
parent | afe51afcc6b7c0245fddbd879d369818b54e460a (diff) | |
download | rails-cdf6cf01cb47bdcbc1e011c8f5f72b161f12bf9c.tar.gz rails-cdf6cf01cb47bdcbc1e011c8f5f72b161f12bf9c.tar.bz2 rails-cdf6cf01cb47bdcbc1e011c8f5f72b161f12bf9c.zip |
use ARel rather than generate SQL strings
Diffstat (limited to 'activerecord/lib/active_record/associations/class_methods')
-rw-r--r-- | activerecord/lib/active_record/associations/class_methods/join_dependency.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb index 7c7fa964f8..b1521b3706 100644 --- a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb +++ b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb @@ -33,10 +33,11 @@ module ActiveRecord join_parts.first end - def columns(connection) + def columns join_parts.collect { |join_part| + table = Arel::Nodes::TableAlias.new join_part.aliased_table_name, nil join_part.column_names_with_alias.collect{ |column_name, aliased_name| - "#{connection.quote_table_name join_part.aliased_table_name}.#{connection.quote_column_name column_name} AS #{aliased_name}" + table[column_name].as aliased_name } }.flatten end |