diff --git a/lib/active_record/connection_adapters/sqlserver/database_statements.rb b/lib/active_record/connection_adapters/sqlserver/database_statements.rb index 991f25508..3b112acae 100644 --- a/lib/active_record/connection_adapters/sqlserver/database_statements.rb +++ b/lib/active_record/connection_adapters/sqlserver/database_statements.rb @@ -66,16 +66,16 @@ def internal_exec_sql_query(sql, conn) # Executes the delete statement and returns the number of rows affected. def delete(arel, name = nil, binds = []) - # if binds.any? - # ActiveRecord.deprecator.warn(<<~MSG.squish) - # Passing `binds` as a positional argument to `delete` is - # deprecated and will be removed in Rails 8.3. Use - # `Arel.sql(sql_with_placeholders, *binds)` to carry bind values - # inside the arel node instead — - # `delete(sql, name, binds)` becomes - # `delete(Arel.sql(sql, *binds), name)`. - # MSG - # end + if binds.any? + ActiveRecord.deprecator.warn(<<~MSG.squish) + Passing `binds` as a positional argument to `delete` is + deprecated and will be removed in Rails 8.3. Use + `Arel.sql(sql_with_placeholders, *binds)` to carry bind values + inside the arel node instead — + `delete(sql, name, binds)` becomes + `delete(Arel.sql(sql, *binds), name)`. + MSG + end # Clear query cache if the connection pool is configured to do so. if pool.dirties_query_cache @@ -94,16 +94,16 @@ def delete(arel, name = nil, binds = []) # Executes the update statement and returns the number of rows affected. def update(arel, name = nil, binds = []) - # if binds.any? - # ActiveRecord.deprecator.warn(<<~MSG.squish) - # Passing `binds` as a positional argument to `update` is - # deprecated and will be removed in Rails 8.3. Use - # `Arel.sql(sql_with_placeholders, *binds)` to carry bind values - # inside the arel node instead — - # `update(sql, name, binds)` becomes - # `update(Arel.sql(sql, *binds), name)`. - # MSG - # end + if binds.any? + ActiveRecord.deprecator.warn(<<~MSG.squish) + Passing `binds` as a positional argument to `update` is + deprecated and will be removed in Rails 8.3. Use + `Arel.sql(sql_with_placeholders, *binds)` to carry bind values + inside the arel node instead — + `update(sql, name, binds)` becomes + `update(Arel.sql(sql, *binds), name)`. + MSG + end # Clear query cache if the connection pool is configured to do so. if pool.dirties_query_cache diff --git a/test/cases/coerced_tests.rb b/test/cases/coerced_tests.rb index 3cd5c8842..24ed2a675 100644 --- a/test/cases/coerced_tests.rb +++ b/test/cases/coerced_tests.rb @@ -1057,7 +1057,7 @@ def test_condition_local_time_interpolation_with_default_timezone_utc_coerced end end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_include_on_unloaded_relation_with_match def test_include_on_unloaded_relation_with_match_coerced assert_queries_match(/1 AS one.*FETCH NEXT @2 ROWS ONLY/) do @@ -1065,7 +1065,7 @@ def test_include_on_unloaded_relation_with_match_coerced end end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_include_on_unloaded_relation_without_match def test_include_on_unloaded_relation_without_match_coerced assert_queries_match(/1 AS one.*FETCH NEXT @2 ROWS ONLY/) do @@ -1073,7 +1073,7 @@ def test_include_on_unloaded_relation_without_match_coerced end end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_member_on_unloaded_relation_with_match def test_member_on_unloaded_relation_with_match_coerced assert_queries_match(/1 AS one.*FETCH NEXT @2 ROWS ONLY/) do @@ -1081,7 +1081,7 @@ def test_member_on_unloaded_relation_with_match_coerced end end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_member_on_unloaded_relation_without_match def test_member_on_unloaded_relation_without_match_coerced assert_queries_match(/1 AS one.*FETCH NEXT @2 ROWS ONLY/) do @@ -1089,7 +1089,7 @@ def test_member_on_unloaded_relation_without_match_coerced end end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_implicit_order_column_is_configurable_with_a_single_value def test_implicit_order_column_is_configurable_with_a_single_value_coerced old_implicit_order_column = Topic.implicit_order_column @@ -1106,7 +1106,7 @@ def test_implicit_order_column_is_configurable_with_a_single_value_coerced Topic.implicit_order_column = old_implicit_order_column end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_implicit_order_column_is_configurable_with_multiple_values def test_implicit_order_column_is_configurable_with_multiple_values_coerced old_implicit_order_column = Topic.implicit_order_column @@ -1119,7 +1119,7 @@ def test_implicit_order_column_is_configurable_with_multiple_values_coerced Topic.implicit_order_column = old_implicit_order_column end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_ordering_does_not_append_primary_keys_or_query_constraints_if_passed_an_implicit_order_column_array_ending_in_nil def test_ordering_does_not_append_primary_keys_or_query_constraints_if_passed_an_implicit_order_column_array_ending_in_nil_coerced old_implicit_order_column = Topic.implicit_order_column @@ -1132,7 +1132,7 @@ def test_ordering_does_not_append_primary_keys_or_query_constraints_if_passed_an Topic.implicit_order_column = old_implicit_order_column end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_implicit_order_set_to_primary_key def test_implicit_order_set_to_primary_key_coerced old_implicit_order_column = Topic.implicit_order_column @@ -1146,7 +1146,7 @@ def test_implicit_order_set_to_primary_key_coerced Topic.implicit_order_column = old_implicit_order_column end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_implicit_order_for_model_without_primary_key def test_implicit_order_for_model_without_primary_key_coerced old_implicit_order_column = NonPrimaryKey.implicit_order_column @@ -1161,7 +1161,7 @@ def test_implicit_order_for_model_without_primary_key_coerced NonPrimaryKey.implicit_order_column = old_implicit_order_column end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_member_on_unloaded_relation_with_composite_primary_key def test_member_on_unloaded_relation_with_composite_primary_key_coerced assert_queries_match(/1 AS one.* FETCH NEXT @3 ROWS ONLY/) do @@ -1170,7 +1170,7 @@ def test_member_on_unloaded_relation_with_composite_primary_key_coerced end end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_implicit_order_column_prepends_query_constraints def test_implicit_order_column_prepends_query_constraints_coerced c = ClothingItem.lease_connection @@ -1186,7 +1186,7 @@ def test_implicit_order_column_prepends_query_constraints_coerced ClothingItem.implicit_order_column = nil end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! %r{#last for a model with composite query constraints} test "#last for a model with composite query constraints coerced" do c = ClothingItem.lease_connection @@ -1198,7 +1198,7 @@ def test_implicit_order_column_prepends_query_constraints_coerced end end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! %r{#first for a model with composite query constraints} test "#first for a model with composite query constraints coerced" do c = ClothingItem.lease_connection @@ -1210,7 +1210,7 @@ def test_implicit_order_column_prepends_query_constraints_coerced end end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_implicit_order_column_reorders_query_constraints def test_implicit_order_column_reorders_query_constraints_coerced c = ClothingItem.lease_connection @@ -1225,7 +1225,7 @@ def test_implicit_order_column_reorders_query_constraints_coerced ClothingItem.implicit_order_column = nil end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_include_on_unloaded_relation_with_composite_primary_key def test_include_on_unloaded_relation_with_composite_primary_key_coerced assert_queries_match(/1 AS one.*OFFSET 0 ROWS FETCH NEXT @(\d) ROWS ONLY/) do @@ -1234,7 +1234,7 @@ def test_include_on_unloaded_relation_with_composite_primary_key_coerced end end - # Check for `FETCH NEXT x ROWS` rather then `LIMIT`. + # Check for `FETCH NEXT x ROWS` rather than `LIMIT`. coerce_tests! :test_nth_to_last_with_order_uses_limit def test_nth_to_last_with_order_uses_limit_coerced c = Topic.lease_connection @@ -2928,3 +2928,8 @@ def test_sql_events_do_not_overlap_with_savepoints_coerced ActiveSupport::Notifications.unsubscribe(subscriber) end end + +class HasManyThroughAssociationsTest < ActiveRecord::TestCase + # SQL Server does not support delete based on composite key from another table. + coerce_tests! :test_delete_all_nullify_on_through_with_composite_source_foreign_key +end