@@ -1675,8 +1675,34 @@ def marshal_fixture_path(file_name)
16751675 end
16761676end
16771677
1678+ class NestedThroughAssociationsTest < ActiveRecord ::TestCase
1679+ # Same as original but replace order with "order(:id)" to ensure that assert_includes_and_joins_equal doesn't raise
1680+ # "A column has been specified more than once in the order by list"
1681+ # Example: original test generate queries like "ORDER BY authors.id, [authors].[id]". We don't support duplicate columns in the order list
1682+ coerce_tests! :test_has_many_through_has_many_with_has_many_through_habtm_source_reflection_preload_via_joins , :test_has_many_through_has_and_belongs_to_many_with_has_many_source_reflection_preload_via_joins
1683+ def test_has_many_through_has_many_with_has_many_through_habtm_source_reflection_preload_via_joins_coerced
1684+ # preload table schemas
1685+ Author . joins ( :category_post_comments ) . first
1686+
1687+ assert_includes_and_joins_equal (
1688+ Author . where ( "comments.id" => comments ( :does_it_hurt ) . id ) . order ( :id ) ,
1689+ [ authors ( :david ) , authors ( :mary ) ] , :category_post_comments
1690+ )
1691+ end
1692+
1693+ def test_has_many_through_has_and_belongs_to_many_with_has_many_source_reflection_preload_via_joins_coerced
1694+ # preload table schemas
1695+ Category . joins ( :post_comments ) . first
1696+
1697+ assert_includes_and_joins_equal (
1698+ Category . where ( "comments.id" => comments ( :more_greetings ) . id ) . order ( :id ) ,
1699+ [ categories ( :general ) , categories ( :technology ) ] , :post_comments
1700+ )
1701+ end
1702+ end
1703+
16781704class BasePreventWritesTest < ActiveRecord ::TestCase
1679- # We open one transaction, not two. Same as original but checking one query
1705+ # SQL Server does not have query for release_savepoint
16801706 coerce_tests! %r{an empty transaction does not raise if preventing writes}
16811707 test "an empty transaction does not raise if preventing writes coerced" do
16821708 ActiveRecord ::Base . while_preventing_writes do
@@ -1690,7 +1716,7 @@ class BasePreventWritesTest < ActiveRecord::TestCase
16901716end
16911717
16921718class BasePreventWritesLegacyTest < ActiveRecord ::TestCase
1693- # We open one transaction, not two. Same as original but checking one query
1719+ # SQL Server does not have query for release_savepoint
16941720 coerce_tests! %r{an empty transaction does not raise if preventing writes}
16951721 test "an empty transaction does not raise if preventing writes coerced" do
16961722 ActiveRecord ::Base . connection_handler . while_preventing_writes do
0 commit comments