@@ -77,6 +77,26 @@ def test_partial_index_coerced
7777 end
7878end
7979
80+ module ActiveRecord
81+ class Migration ::IndexTest < ActiveRecord ::TestCase
82+ # SQL Server requires an explicit truthy comparison for BIT columns.
83+ coerce_tests! :test_rename_index_preserves_where_clause
84+ def test_rename_index_preserves_where_clause_coerced
85+ skip unless connection . supports_partial_index?
86+
87+ # Keep the names short to make Oracle and similar behave.
88+ connection . add_index ( table_name , [ :foo ] , name : "old_idx" , where : "administrator = 1" )
89+ old_where = connection . indexes ( table_name ) . find { |i | i . name == "old_idx" } . where
90+
91+ connection . rename_index ( table_name , "old_idx" , "new_idx" )
92+
93+ new_index = connection . indexes ( table_name ) . find { |i | i . name == "new_idx" }
94+ assert_not_nil new_index
95+ assert_equal old_where , new_index . where
96+ end
97+ end
98+ end
99+
80100module ActiveRecord
81101 class AdapterTest < ActiveRecord ::TestCase
82102 # Legacy binds are not supported.
@@ -2039,7 +2059,6 @@ class UnsafeRawSqlTest < ActiveRecord::TestCase
20392059 test "order: allows nested functions" do
20402060 ids_expected = Post . order ( Arel . sql ( "author_id, len(trim(title))" ) ) . pluck ( :id )
20412061
2042- # $DEBUG = true
20432062 ids = Post . order ( "author_id, len(trim(title))" ) . pluck ( :id )
20442063
20452064 assert_equal ids_expected , ids
0 commit comments