aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/alias_tracker.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-10-09 15:18:59 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-10-09 16:06:04 +0900
commitc5ab6e51a7b9ee05a2d262a72c7130b9c1d1b0ce (patch)
tree2d8ac7f3e896045390ec35455cf61a0bc25275f5 /activerecord/lib/active_record/associations/alias_tracker.rb
parentb1e7bb9ed7ddbb29fd788dee1c3f2ba2626bd7ac (diff)
downloadrails-c5ab6e51a7b9ee05a2d262a72c7130b9c1d1b0ce.tar.gz
rails-c5ab6e51a7b9ee05a2d262a72c7130b9c1d1b0ce.tar.bz2
rails-c5ab6e51a7b9ee05a2d262a72c7130b9c1d1b0ce.zip
Joined tables in association scope doesn't use the same aliases with the parent relation's aliases
Building association scope in join dependency should respect the parent relation's aliases to avoid using the same alias name more than once. Fixes #30681.
Diffstat (limited to 'activerecord/lib/active_record/associations/alias_tracker.rb')
-rw-r--r--activerecord/lib/active_record/associations/alias_tracker.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/alias_tracker.rb b/activerecord/lib/active_record/associations/alias_tracker.rb
index 358cdabc7f..a8d8ee268a 100644
--- a/activerecord/lib/active_record/associations/alias_tracker.rb
+++ b/activerecord/lib/active_record/associations/alias_tracker.rb
@@ -30,6 +30,8 @@ module ActiveRecord
).size
elsif join.respond_to? :left
join.left.table_name == name ? 1 : 0
+ elsif join.is_a?(Hash)
+ join[name]
else
# this branch is reached by two tests:
#
@@ -73,10 +75,7 @@ module ActiveRecord
end
end
- # TODO Change this to private once we've dropped Ruby 2.2 support.
- # Workaround for Ruby 2.2 "private attribute?" warning.
- protected
- attr_reader :aliases
+ attr_reader :aliases
private