diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-07 17:05:15 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-07 17:05:15 -0800 |
commit | d98cb5153dad97cde82ec91a1993043cfa9bc0e4 (patch) | |
tree | 7f11d288aceebb754c11c44156d94f0186d6ecb2 /activerecord/lib/active_record/associations/class_methods/join_dependency.rb | |
parent | 2d9d6cd4c263f639adf8e26c7d95e7772e0c4eb7 (diff) | |
download | rails-d98cb5153dad97cde82ec91a1993043cfa9bc0e4.tar.gz rails-d98cb5153dad97cde82ec91a1993043cfa9bc0e4.tar.bz2 rails-d98cb5153dad97cde82ec91a1993043cfa9bc0e4.zip |
JoinDependency is always created with an AST now
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.rb | 14 |
1 files changed, 10 insertions, 4 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 86d43f21d3..928e8152a5 100644 --- a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb +++ b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb @@ -49,10 +49,16 @@ module ActiveRecord return count_aliases_from_string(@table_joins.downcase, name) if String === @table_joins - @table_joins.grep(Arel::Table).find_all { |table| - table.name.downcase == name - }.length + @table_joins.grep(String).map { |s| - count_aliases_from_string(s, name) + @table_joins.grep(Arel::Nodes::Join).map { |join| + right = join.right + case right + when Arel::Table + right.name.downcase == name ? 1 : 0 + when String + count_aliases_from_string(right.downcase, name) + else + 0 + end }.sum end |