diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2017-07-25 11:48:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-25 11:48:45 -0400 |
commit | b6033773c1f02cc91155ef10a223f4bc1c176965 (patch) | |
tree | 3f0bdbaea2315d492d9af04bdce6b321e70ebb80 /activerecord/lib/active_record | |
parent | 2a2349699dcfc69295f0868bfe29b129a84dab7a (diff) | |
parent | ea37a5709b526c5e58ef5b96a27c62cf222a52c4 (diff) | |
download | rails-b6033773c1f02cc91155ef10a223f4bc1c176965.tar.gz rails-b6033773c1f02cc91155ef10a223f4bc1c176965.tar.bz2 rails-b6033773c1f02cc91155ef10a223f4bc1c176965.zip |
Merge pull request #29934 from kamipo/remove_join_information
Remove useless `JoinInformation`
Diffstat (limited to 'activerecord/lib/active_record')
3 files changed, 5 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 2c3d5b3429..dc029c08bd 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -174,9 +174,9 @@ module ActiveRecord def make_join_constraints(parent, child, join_type, aliasing = false) tables = aliasing ? table_aliases_for(parent, child) : child.tables - info = make_constraints(parent, child, tables, join_type) + joins = make_constraints(parent, child, tables, join_type) - [info] + child.children.flat_map { |c| make_join_constraints(child, c, join_type, aliasing) } + joins.concat child.children.flat_map { |c| make_join_constraints(child, c, join_type, aliasing) } end def table_aliases_for(parent, node) diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index 30dbdb7fa5..a526468bf6 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -23,8 +23,6 @@ module ActiveRecord super && reflection == other.reflection end - JoinInformation = Struct.new :joins - def join_constraints(foreign_table, foreign_klass, join_type, tables, chain) joins = [] tables = tables.reverse @@ -51,7 +49,7 @@ module ActiveRecord foreign_table, foreign_klass = table, klass end - JoinInformation.new joins + joins end def table diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 812c8e7e3f..a51cf4319e 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -1014,11 +1014,8 @@ module ActiveRecord klass, table, association_joins, join_list ) - join_infos = join_dependency.join_constraints stashed_association_joins, join_type - - join_infos.each do |info| - info.joins.each { |join| manager.from(join) } - end + joins = join_dependency.join_constraints(stashed_association_joins, join_type) + joins.each { |join| manager.from(join) } manager.join_sources.concat(join_list) |