diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-24 13:29:18 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-24 13:55:55 -0800 |
commit | d4b8d3bafa54e233d3f1ef43c43bfb460d9f2435 (patch) | |
tree | 2eb3efb034c742d04a2edbbdb891f0b941db7999 /activerecord | |
parent | a3ba60fd814a980cc929fcbe0f9d48fa4d0292e5 (diff) | |
download | rails-d4b8d3bafa54e233d3f1ef43c43bfb460d9f2435.tar.gz rails-d4b8d3bafa54e233d3f1ef43c43bfb460d9f2435.tar.bz2 rails-d4b8d3bafa54e233d3f1ef43c43bfb460d9f2435.zip |
moving column_aliases to JoinDependency
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/class_methods/join_dependency.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 11 |
2 files changed, 9 insertions, 10 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 79fdb2d4cb..87541e0529 100644 --- a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb +++ b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb @@ -33,6 +33,14 @@ module ActiveRecord join_parts.first end + def columns(connection) + join_parts.collect { |join_part| + 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}" + } + }.flatten.join(", ") + end + def count_aliases_from_table_joins(name) # quoted_name should be downcased as some database adapters (Oracle) return quoted name in uppercase quoted_name = join_base.active_record.connection.quote_table_name(name.downcase).downcase diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 4192456447..74ec83091c 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(column_aliases(join_dependency)) + relation = except(:includes, :eager_load, :preload, :select).select(join_dependency.columns(connection)) apply_join_dependency(relation, join_dependency) end @@ -349,17 +349,8 @@ module ActiveRecord end end - def column_aliases(join_dependency) - join_dependency.join_parts.collect { |join_part| - 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}" - } - }.flatten.join(", ") - end - def using_limitable_reflections?(reflections) reflections.none? { |r| r.collection? } end - end end |