diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-09 15:21:34 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-09 15:21:34 -0700 |
commit | 752a06ea8d76a072a4cf51594f47d8a4c6c2edd6 (patch) | |
tree | db9bd6a0574dbd0ba4df7a148d0a197235e0532d /activerecord | |
parent | 92f95bbb33346cc6a8e7e07e51696ad10e1a6fc7 (diff) | |
download | rails-752a06ea8d76a072a4cf51594f47d8a4c6c2edd6.tar.gz rails-752a06ea8d76a072a4cf51594f47d8a4c6c2edd6.tar.bz2 rails-752a06ea8d76a072a4cf51594f47d8a4c6c2edd6.zip |
hide join_constraints inside the JoinDependency object
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency.rb | 12 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 3 |
2 files changed, 7 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 433855ceea..4d1f7a1041 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -75,20 +75,20 @@ module ActiveRecord self end - def join_associations - join_root.drop 1 - end - def reflections - join_associations.map(&:reflection) + join_root.drop(1).map(&:reflection) end def join_relation(relation) - join_associations.inject(relation) do |rel,association| + join_root.drop(1).inject(relation) do |rel,association| association.join_relation(rel) end end + def join_constraints + join_root.drop(1).flat_map(&:join_constraints) + end + def columns join_root.collect { |join_part| table = join_part.aliased_table diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 9fcb6db726..e1efc6a189 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -952,8 +952,7 @@ module ActiveRecord join_dependency.graft(*stashed_association_joins) - joins = join_dependency.join_associations.map!(&:join_constraints) - joins.flatten! + joins = join_dependency.join_constraints joins.each { |join| manager.from(join) } |