Skip to content

Commit 5e298a7

Browse files
author
Aidan Haran
committed
Rails test was renamed and so the coerced test should have been renamed instead of removed
1 parent 854ad39 commit 5e298a7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,28 @@ def test_insert_all_coerced
16031603
end
16041604
end
16051605

1606+
require "models/citation"
1607+
class EagerLoadingTooManyIdsTest < ActiveRecord::TestCase
1608+
# Original Rails test fails with SQL Server error message "The query processor ran out of internal resources and
1609+
# could not produce a query plan". This error goes away if you change database compatibility level to 110 (SQL 2012)
1610+
# (see https://www.mssqltips.com/sqlservertip/5279/sql-server-error-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan/).
1611+
# However, you cannot change the compatibility level during a test. The purpose of the test is to ensure that an
1612+
# unprepared statement is used if the number of values exceeds the adapter's `bind_params_length`. The coerced test
1613+
# still does this as there will be 32,768 remaining citation records in the database and the `bind_params_length` of
1614+
# adapter is 2,098.
1615+
coerce_tests! :test_eager_loading_too_many_ids
1616+
def test_eager_loading_too_many_ids_coerced
1617+
# Remove excess records.
1618+
Citation.limit(32768).order(id: :desc).delete_all
1619+
1620+
# Perform test
1621+
citation_count = Citation.count
1622+
assert_sql(/WHERE \(\[citations\]\.\[id\] IN \(0, 1/) do
1623+
assert_equal citation_count, Citation.eager_load(:citations).offset(0).size
1624+
end
1625+
end
1626+
end
1627+
16061628
class LogSubscriberTest < ActiveRecord::TestCase
16071629
# Call original test from coerced test. Fixes issue on CI with Rails installed as a gem.
16081630
coerce_tests! :test_vebose_query_logs

0 commit comments

Comments
 (0)