From 402f2f2151c8b6207815e4ebaba34d7d8f0e4b23 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 6 Jun 2026 15:10:31 +0000 Subject: [PATCH 1/2] Coerce partial index rename test for SQL Server --- test/cases/coerced_tests.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/cases/coerced_tests.rb b/test/cases/coerced_tests.rb index 3f553579d..f495a5776 100644 --- a/test/cases/coerced_tests.rb +++ b/test/cases/coerced_tests.rb @@ -77,6 +77,26 @@ def test_partial_index_coerced end end +module ActiveRecord + class Migration::IndexTest < ActiveRecord::TestCase + # SQL Server requires an explicit truthy comparison for BIT columns. + coerce_tests! :test_rename_index_preserves_where_clause + def test_rename_index_preserves_where_clause_coerced + skip unless connection.supports_partial_index? + + # Keep the names short to make Oracle and similar behave. + connection.add_index(table_name, [:foo], name: "old_idx", where: "administrator = 1") + old_where = connection.indexes(table_name).find { |i| i.name == "old_idx" }.where + + connection.rename_index(table_name, "old_idx", "new_idx") + + new_index = connection.indexes(table_name).find { |i| i.name == "new_idx" } + assert_not_nil new_index + assert_equal old_where, new_index.where + end + end +end + module ActiveRecord class AdapterTest < ActiveRecord::TestCase # Legacy binds are not supported. From fc1f8f940c872f8fe8722adb08d3ec9bf494df42 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Sun, 7 Jun 2026 11:50:09 +0100 Subject: [PATCH 2/2] Cleanup --- test/cases/coerced_tests.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cases/coerced_tests.rb b/test/cases/coerced_tests.rb index f495a5776..348856828 100644 --- a/test/cases/coerced_tests.rb +++ b/test/cases/coerced_tests.rb @@ -2059,7 +2059,6 @@ class UnsafeRawSqlTest < ActiveRecord::TestCase test "order: allows nested functions" do ids_expected = Post.order(Arel.sql("author_id, len(trim(title))")).pluck(:id) - # $DEBUG = true ids = Post.order("author_id, len(trim(title))").pluck(:id) assert_equal ids_expected, ids