diff --git a/test/cases/coerced_tests.rb b/test/cases/coerced_tests.rb index 66bee9fe9..1cea29b68 100644 --- a/test/cases/coerced_tests.rb +++ b/test/cases/coerced_tests.rb @@ -473,7 +473,7 @@ def test_select_avg_with_joins_and_group_by_as_virtual_attribute_with_ar_coerced # Match SQL Server limit implementation coerce_tests! :test_limit_is_kept def test_limit_is_kept_coerced - queries = capture_sql_ss { Account.limit(1).count } + queries = capture_sql { Account.limit(1).count } assert_equal 1, queries.length assert_match(/ORDER BY \[accounts\]\.\[id\] ASC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY.*@0 = 1/, queries.first) end @@ -481,7 +481,7 @@ def test_limit_is_kept_coerced # Match SQL Server limit implementation coerce_tests! :test_limit_with_offset_is_kept def test_limit_with_offset_is_kept_coerced - queries = capture_sql_ss { Account.limit(1).offset(1).count } + queries = capture_sql { Account.limit(1).offset(1).count } assert_equal 1, queries.length assert_match(/ORDER BY \[accounts\]\.\[id\] ASC OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY.*@0 = 1, @1 = 1/, queries.first) end @@ -1337,30 +1337,6 @@ def test_cache_does_not_wrap_results_in_arrays_coerced assert_equal 2, Task.lease_connection.select_value("SELECT count(*) AS count_all FROM tasks") end end - - # Same as original test except that we expect one query to be performed to retrieve the table's primary key - # and we don't call `reload_type_map` because SQL Server adapter doesn't support it. - # When we generate the SQL for the `find` it includes ordering on the primary key. If we reset the column - # information then the primary key needs to be retrieved from the database again to generate the SQL causing the - # original test's `assert_no_queries` assertion to fail. Assert that the query was to get the primary key. - coerce_tests! :test_query_cached_even_when_types_are_reset - def test_query_cached_even_when_types_are_reset_coerced - Task.cache do - # Warm the cache - Task.find(1) - - # Clear places where type information is cached - Task.reset_column_information - Task.initialize_find_by_cache - Task.define_attribute_methods - - assert_queries_count(1, include_schema: true) do - Task.find(1) - end - - assert_includes ActiveRecord::SQLCounter.log_all.first, "TC.CONSTRAINT_TYPE = N''PRIMARY KEY''" - end - end end require "models/post" @@ -1648,7 +1624,7 @@ def test_releasing_named_savepoints_coerced def test_nested_transactions_after_disable_lazy_transactions_coerced Topic.lease_connection.disable_lazy_transactions! - capture_sql do + actual_queries = capture_sql(include_schema: true) do # RealTransaction (begin..commit) Topic.transaction(requires_new: true) do # ResetParentTransaction (no queries) @@ -1666,8 +1642,6 @@ def test_nested_transactions_after_disable_lazy_transactions_coerced end end - actual_queries = ActiveRecord::SQLCounter.log_all - expected_queries = [ /BEGIN/i, /DELETE/i, @@ -1685,7 +1659,7 @@ def test_nested_transactions_after_disable_lazy_transactions_coerced # SQL Server does not have query for release_savepoint. coerce_tests! :test_nested_transactions_skip_excess_savepoints def test_nested_transactions_skip_excess_savepoints_coerced - capture_sql do + actual_queries = capture_sql(include_schema: true) do # RealTransaction (begin..commit) Topic.transaction(requires_new: true) do # ResetParentTransaction (no queries) @@ -1703,8 +1677,6 @@ def test_nested_transactions_skip_excess_savepoints_coerced end end - actual_queries = ActiveRecord::SQLCounter.log_all - expected_queries = [ /BEGIN/i, /DELETE/i, diff --git a/test/cases/helper_sqlserver.rb b/test/cases/helper_sqlserver.rb index 4435eb95b..097330370 100644 --- a/test/cases/helper_sqlserver.rb +++ b/test/cases/helper_sqlserver.rb @@ -10,7 +10,6 @@ require "cases/helper" require "support/load_schema_sqlserver" require "support/coerceable_test_sqlserver" -require "support/sql_counter_sqlserver" require "support/connection_reflection" require "mocha/minitest" @@ -20,7 +19,6 @@ class TestCase < ActiveSupport::TestCase include ARTest::SQLServer::CoerceableTest, ARTest::SQLServer::ConnectionReflection, - ARTest::SQLServer::SqlCounterSqlserver, ActiveSupport::Testing::Stream let(:logger) { ActiveRecord::Base.logger } diff --git a/test/support/sql_counter_sqlserver.rb b/test/support/sql_counter_sqlserver.rb deleted file mode 100644 index 7144a4fd7..000000000 --- a/test/support/sql_counter_sqlserver.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module ARTest - module SQLServer - module SqlCounterSqlserver - # Only return the log vs. log_all - def capture_sql_ss - ActiveRecord::SQLCounter.clear_log - yield - ActiveRecord::SQLCounter.log.dup - end - end - end -end