Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
37 changes: 21 additions & 16 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1057,39 +1057,39 @@ 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
assert_equal true, Customer.where(name: "David").include?(customers(:david))
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
assert_equal false, Customer.where(name: "David").include?(customers(:mary))
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
assert_equal true, Customer.where(name: "David").member?(customers(:david))
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
assert_equal false, Customer.where(name: "David").member?(customers(:mary))
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Loading