aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRafael França <rafael@franca.dev>2019-07-26 13:57:23 -0400
committerGitHub <noreply@github.com>2019-07-26 13:57:23 -0400
commitf825a9048fc98c9c964fe23b567e4d555b938d77 (patch)
treee5bc72c6d2c8eee92eafff606d82c9b747d301a8 /activerecord/test
parent1760fe919f51cfdcb375847e1ed4a9c0f4827720 (diff)
parent285f081e1ddf0a552ae1331a76cdaa90a51f319c (diff)
downloadrails-f825a9048fc98c9c964fe23b567e4d555b938d77.tar.gz
rails-f825a9048fc98c9c964fe23b567e4d555b938d77.tar.bz2
rails-f825a9048fc98c9c964fe23b567e4d555b938d77.zip
Merge pull request #36776 from giraffate/fix_join_middle_table_alias_when_using_HABTM
Fix join middle table alias when using HABTM
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index 25cfa0a723..de9742b250 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -700,10 +700,17 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
assert_equal ["id"], developers(:david).projects.select(:id).first.attributes.keys
end
+ def test_join_middle_table_alias
+ assert_equal(
+ 2,
+ Project.includes(:developers_projects).where.not("developers_projects.joined_on": nil).to_a.size
+ )
+ end
+
def test_join_table_alias
assert_equal(
3,
- Developer.includes(projects: :developers).where.not("projects_developers_projects_join.joined_on": nil).to_a.size
+ Developer.includes(projects: :developers).where.not("developers_projects_projects_join.joined_on": nil).to_a.size
)
end
@@ -716,7 +723,7 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
assert_equal(
3,
- Developer.includes(projects: :developers).where.not("projects_developers_projects_join.joined_on": nil).group(group.join(",")).to_a.size
+ Developer.includes(projects: :developers).where.not("developers_projects_projects_join.joined_on": nil).group(group.join(",")).to_a.size
)
end