aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-24 13:53:55 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-24 13:55:56 -0800
commit34d21b87bb237bf55214bd476be71116a2a5258f (patch)
treed5129002b762d702cd34b6c54b440290012feb1f /activerecord
parentcdf6cf01cb47bdcbc1e011c8f5f72b161f12bf9c (diff)
downloadrails-34d21b87bb237bf55214bd476be71116a2a5258f.tar.gz
rails-34d21b87bb237bf55214bd476be71116a2a5258f.tar.bz2
rails-34d21b87bb237bf55214bd476be71116a2a5258f.zip
adding a factory method to the join part for generating a table alias
Diffstat (limited to 'activerecord')
-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