aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-06-26 03:48:18 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-06-26 03:48:18 +0900
commit5eed3bba5e10bd3aeb3a1ca1d3037268e1de1148 (patch)
tree3eeac8bf2e26aff5fa3739438504ea24e6303f2c /activerecord
parentb2eb1d1c55a59fee1e6c4cba7030d8ceb524267c (diff)
downloadrails-5eed3bba5e10bd3aeb3a1ca1d3037268e1de1148.tar.gz
rails-5eed3bba5e10bd3aeb3a1ca1d3037268e1de1148.tar.bz2
rails-5eed3bba5e10bd3aeb3a1ca1d3037268e1de1148.zip
Use `reflection.alias_candidate` in `table_alias_for`
The "join" affix in `table_alias_for` was added 12 years ago at 02d3444 to address poor alias tracking. `AssociationScope` no longer uses the "join" suffixed alias since 0408e21 and had been removed at a1ec8b5. `table_alias_for` is the last place that using the useless legacy suffixed alias, but we can't remove the suffix since some test cases directly refers the alias name by `where` with string literal, so at least removing the suffix would break our test cases. (e.g. https://github.com/rails/rails/blob/b2eb1d1c55a59fee1e6c4cba7030d8ceb524267c/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb#L699-L731).
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb
index 0835d2cc9b..8cf1b5d25a 100644
--- a/activerecord/lib/active_record/associations/join_dependency.rb
+++ b/activerecord/lib/active_record/associations/join_dependency.rb
@@ -172,7 +172,7 @@ module ActiveRecord
end
def table_alias_for(reflection, parent, join)
- name = "#{reflection.plural_name}_#{parent.table_name}"
+ name = reflection.alias_candidate(parent.table_name)
join ? "#{name}_join" : name
end