aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-24 13:40:23 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-24 13:55:55 -0800
commitcdf6cf01cb47bdcbc1e011c8f5f72b161f12bf9c (patch)
tree799f62fd5996189bc16dda689ecdc4d82f7c8496
parentafe51afcc6b7c0245fddbd879d369818b54e460a (diff)
downloadrails-cdf6cf01cb47bdcbc1e011c8f5f72b161f12bf9c.tar.gz
rails-cdf6cf01cb47bdcbc1e011c8f5f72b161f12bf9c.tar.bz2
rails-cdf6cf01cb47bdcbc1e011c8f5f72b161f12bf9c.zip
use ARel rather than generate SQL strings
-rw-r--r--activerecord/lib/active_record/associations/class_methods/join_dependency.rb5
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb2
2 files changed, 4 insertions, 3 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
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 74ec83091c..23ae0b4325 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -202,7 +202,7 @@ module ActiveRecord
end
def construct_relation_for_association_find(join_dependency)
- relation = except(:includes, :eager_load, :preload, :select).select(join_dependency.columns(connection))
+ relation = except(:includes, :eager_load, :preload, :select).select(join_dependency.columns)
apply_join_dependency(relation, join_dependency)
end