diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-27 18:47:42 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-27 18:47:42 +0900 |
commit | 23bcc6578e28355cc7258c744bcb26c0c80524ef (patch) | |
tree | feac5c96d3e473210c89f97829d041ace2f551ed /activerecord/lib/active_record/associations | |
parent | 61cc630ac7e7f8554dc049a3e5a2509c00303ef8 (diff) | |
download | rails-23bcc6578e28355cc7258c744bcb26c0c80524ef.tar.gz rails-23bcc6578e28355cc7258c744bcb26c0c80524ef.tar.bz2 rails-23bcc6578e28355cc7258c744bcb26c0c80524ef.zip |
Move constructing polymorphic type to `join_scope` in `Reflection`
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency/join_association.rb | 12 |
1 files changed, 2 insertions, 10 deletions
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 95f16c622e..70520b8e85 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -40,21 +40,13 @@ module ActiveRecord constraint = build_constraint(klass, table, key, foreign_table, foreign_key) - rel = reflection.join_scope(table) + rel = reflection.join_scope(table, foreign_klass) - if rel && !rel.arel.constraints.empty? + if rel.arel.constraints.any? binds += rel.bound_attributes constraint = constraint.and rel.arel.constraints end - if reflection.type - value = foreign_klass.base_class.name - column = klass.columns_hash[reflection.type.to_s] - - binds << Relation::QueryAttribute.new(column.name, value, klass.type_for_attribute(column.name)) - constraint = constraint.and klass.arel_attribute(reflection.type, table).eq(Arel::Nodes::BindParam.new) - end - joins << table.create_join(table, table.create_on(constraint), join_type) # The current table in this iteration becomes the foreign table in the next |