aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/class_methods/join_dependency.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-24 13:29:18 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-24 13:55:55 -0800
commitd4b8d3bafa54e233d3f1ef43c43bfb460d9f2435 (patch)
tree2eb3efb034c742d04a2edbbdb891f0b941db7999 /activerecord/lib/active_record/associations/class_methods/join_dependency.rb
parenta3ba60fd814a980cc929fcbe0f9d48fa4d0292e5 (diff)
downloadrails-d4b8d3bafa54e233d3f1ef43c43bfb460d9f2435.tar.gz
rails-d4b8d3bafa54e233d3f1ef43c43bfb460d9f2435.tar.bz2
rails-d4b8d3bafa54e233d3f1ef43c43bfb460d9f2435.zip
moving column_aliases to JoinDependency
Diffstat (limited to 'activerecord/lib/active_record/associations/class_methods/join_dependency.rb')
-rw-r--r--activerecord/lib/active_record/associations/class_methods/join_dependency.rb8
1 files changed, 8 insertions, 0 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