Skip to content

Commit 9a94ff4

Browse files
authored
Merge pull request rails#54578 from Edouard-chin/ec-leaky-tests
Fix leaky test:
2 parents 174dfdd + aab1d83 commit 9a94ff4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

activerecord/test/cases/migration_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ def setup
6161
Thing.lease_connection.drop_table(table) rescue nil
6262
end
6363
Thing.reset_column_information
64+
clear_statement_cache(Thing)
6465

6566
%w(reminders people_reminders prefix_reminders_suffix).each do |table|
6667
Reminder.lease_connection.drop_table(table) rescue nil
6768
end
6869
Reminder.reset_table_name
6970
Reminder.reset_column_information
71+
clear_statement_cache(Reminder)
7072

7173
%w(last_name key bio age height wealth birthday favorite_day
7274
moment_of_truth male administrator funny).each do |column|
@@ -76,6 +78,7 @@ def setup
7678
Person.lease_connection.remove_column("people", "middle_name") rescue nil
7779
Person.lease_connection.add_column("people", "first_name", :string)
7880
Person.reset_column_information
81+
clear_statement_cache(Person)
7982

8083
ActiveRecord::Migration.verbose = @verbose_was
8184
end
@@ -1131,6 +1134,12 @@ def self.base_class; self; end
11311134
}
11321135
end
11331136

1137+
def clear_statement_cache(model)
1138+
model.connection_handler.each_connection_pool do |pool|
1139+
pool.connections.each(&:clear_cache!)
1140+
end
1141+
end
1142+
11341143
def with_another_process_holding_lock(lock_id)
11351144
thread_lock = Concurrent::CountDownLatch.new
11361145
test_terminated = Concurrent::CountDownLatch.new

0 commit comments

Comments
 (0)