diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-10-02 06:39:42 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-10-09 09:45:32 +0900 |
commit | 723b526158df576f673c1bc28439744378a03f5d (patch) | |
tree | 664a936a632fe32a48e70c3f0767aa550a02d537 /activerecord/lib/active_record | |
parent | f8337575ac1be1efb2bc89225a369e19fa2a234d (diff) | |
download | rails-723b526158df576f673c1bc28439744378a03f5d.tar.gz rails-723b526158df576f673c1bc28439744378a03f5d.tar.bz2 rails-723b526158df576f673c1bc28439744378a03f5d.zip |
Fix `relation.exists?` with has_many through associations
`relation.exists?` should reference correct aliases while joining tables
of has_many through associations.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 5ccfe3d1b7..6e07402979 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -366,7 +366,7 @@ module ActiveRecord # preexisting join in joins_values to categorizations (by way of # the `has_many :through` for categories). # - join_dependency = construct_join_dependency(joins_values) + join_dependency = construct_join_dependency relation = apply_join_dependency(join_dependency) relation._select!(join_dependency.aliases.columns) @@ -387,15 +387,15 @@ module ActiveRecord relation end - def construct_join_dependency(joins = [], eager_loading: true) + def construct_join_dependency(eager_loading: true) including = eager_load_values + includes_values ActiveRecord::Associations::JoinDependency.new( - klass, table, including, alias_tracker(joins), eager_loading: eager_loading + klass, table, including, alias_tracker(joins_values), eager_loading: eager_loading ) end def construct_relation_for_association_calculations - apply_join_dependency(construct_join_dependency(joins_values)) + apply_join_dependency(construct_join_dependency) end def apply_join_dependency(join_dependency) |