diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-24 13:53:55 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-24 13:55:56 -0800 |
commit | 34d21b87bb237bf55214bd476be71116a2a5258f (patch) | |
tree | d5129002b762d702cd34b6c54b440290012feb1f | |
parent | cdf6cf01cb47bdcbc1e011c8f5f72b161f12bf9c (diff) | |
download | rails-34d21b87bb237bf55214bd476be71116a2a5258f.tar.gz rails-34d21b87bb237bf55214bd476be71116a2a5258f.tar.bz2 rails-34d21b87bb237bf55214bd476be71116a2a5258f.zip |
adding a factory method to the join part for generating a table alias
-rw-r--r-- | activerecord/lib/active_record/associations/class_methods/join_dependency.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/class_methods/join_dependency/join_part.rb | 4 |
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 |