aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-10-02 06:39:42 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-10-09 09:45:32 +0900
commit723b526158df576f673c1bc28439744378a03f5d (patch)
tree664a936a632fe32a48e70c3f0767aa550a02d537 /activerecord/lib
parentf8337575ac1be1efb2bc89225a369e19fa2a234d (diff)
downloadrails-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')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb8
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)