aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/associations/class_methods/join_dependency.rb2
-rw-r--r--activerecord/lib/active_record/associations/class_methods/join_dependency/join_part.rb4
2 files changed, 5 insertions, 1 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 b1521b3706..19d2d55ca0 100644
--- a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb
+++ b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb
@@ -35,7 +35,7 @@ module ActiveRecord
def columns
join_parts.collect { |join_part|
- table = Arel::Nodes::TableAlias.new join_part.aliased_table_name, nil
+ table = join_part.aliased_table
join_part.column_names_with_alias.collect{ |column_name, aliased_name|
table[column_name].as aliased_name
}
diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency/join_part.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency/join_part.rb
index 64d751344d..5d55ca202e 100644
--- a/activerecord/lib/active_record/associations/class_methods/join_dependency/join_part.rb
+++ b/activerecord/lib/active_record/associations/class_methods/join_dependency/join_part.rb
@@ -21,6 +21,10 @@ module ActiveRecord
@cached_record = {}
end
+ def aliased_table
+ Arel::Nodes::TableAlias.new aliased_table_name, table
+ end
+
def ==(other)
raise NotImplementedError
end