Skip to content

Commit 2c89c4f

Browse files
aidanharanAidan Haran
authored andcommitted
Rails test was renamed and so the coerced test should have been renamed instead of removed (rails-sqlserver#909)
Co-authored-by: Aidan Haran <[email protected]>
1 parent 4d4fa8d commit 2c89c4f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,30 @@ def test_insert_all_coerced
16221622
end
16231623
end
16241624

1625+
require "models/citation"
1626+
class EagerLoadingTooManyIdsTest < ActiveRecord::TestCase
1627+
fixtures :citations
1628+
1629+
# Original Rails test fails with SQL Server error message "The query processor ran out of internal resources and
1630+
# could not produce a query plan". This error goes away if you change database compatibility level to 110 (SQL 2012)
1631+
# (see https://www.mssqltips.com/sqlservertip/5279/sql-server-error-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan/).
1632+
# However, you cannot change the compatibility level during a test. The purpose of the test is to ensure that an
1633+
# unprepared statement is used if the number of values exceeds the adapter's `bind_params_length`. The coerced test
1634+
# still does this as there will be 32,768 remaining citation records in the database and the `bind_params_length` of
1635+
# adapter is 2,098.
1636+
coerce_tests! :test_eager_loading_too_many_ids
1637+
def test_eager_loading_too_many_ids_coerced
1638+
# Remove excess records.
1639+
Citation.limit(32768).order(id: :desc).delete_all
1640+
1641+
# Perform test
1642+
citation_count = Citation.count
1643+
assert_sql(/WHERE \[citations\]\.\[id\] IN \(0, 1/) do
1644+
assert_equal citation_count, Citation.eager_load(:citations).offset(0).size
1645+
end
1646+
end
1647+
end
1648+
16251649
class LogSubscriberTest < ActiveRecord::TestCase
16261650
# Call original test from coerced test. Fixes issue on CI with Rails installed as a gem.
16271651
coerce_tests! :test_vebose_query_logs

0 commit comments

Comments
 (0)