aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/inner_join_association_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-10-23 21:42:11 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-10-23 21:53:32 +0900
commit9fedd013475456dc9bdbf0be45a194cc5fc2566e (patch)
treea72e3998cb5216cca3c267ed203e2fb7267faafa /activerecord/test/cases/associations/inner_join_association_test.rb
parentf4d1aa5310284ebceb51970140fa08f6c8ea19b6 (diff)
downloadrails-9fedd013475456dc9bdbf0be45a194cc5fc2566e.tar.gz
rails-9fedd013475456dc9bdbf0be45a194cc5fc2566e.tar.bz2
rails-9fedd013475456dc9bdbf0be45a194cc5fc2566e.zip
Ensure associations doesn't table name collide with string joins
Currently we have no test for alias tracking with string joins. I've add test case for that to catch a future regression.
Diffstat (limited to 'activerecord/test/cases/associations/inner_join_association_test.rb')
-rw-r--r--activerecord/test/cases/associations/inner_join_association_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/inner_join_association_test.rb b/activerecord/test/cases/associations/inner_join_association_test.rb
index 23be344419..d2494cabfa 100644
--- a/activerecord/test/cases/associations/inner_join_association_test.rb
+++ b/activerecord/test/cases/associations/inner_join_association_test.rb
@@ -27,6 +27,11 @@ class InnerJoinAssociationTest < ActiveRecord::TestCase
end
end
+ def test_construct_finder_sql_does_not_table_name_collide_with_string_joins
+ sql = Person.joins(:agents).joins("JOIN people agents_people ON agents_people.primary_contact_id = people.id").to_sql
+ assert_match(/agents_people_2/i, sql)
+ end
+
def test_construct_finder_sql_ignores_empty_joins_hash
sql = Author.joins({}).to_sql
assert_no_match(/JOIN/i, sql)