Skip to content

Commit fde9764

Browse files
committed
Fix YAML load for ruby 3.1.
See ruby/psych#487 for more information.
1 parent 41a6e80 commit fde9764

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

test/cases/coerced_tests.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,8 @@ class YamlSerializationTest < ActiveRecord::TestCase
14861486
coerce_tests! :test_types_of_virtual_columns_are_not_changed_on_round_trip
14871487
def test_types_of_virtual_columns_are_not_changed_on_round_trip_coerced
14881488
author = Author.select("authors.*, 5 as posts_count").first
1489-
dumped = YAML.load(YAML.dump(author))
1489+
dumped_author = YAML.dump(author)
1490+
dumped = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(dumped_author) : YAML.load(dumped_author)
14901491
assert_equal 5, author.posts_count
14911492
assert_equal 5, dumped.posts_count
14921493
end

test/cases/rake_test_sqlserver.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ class SQLServerRakeSchemaCacheDumpLoadTest < SQLServerRakeTest
176176
it "dumps schema cache with SQL Server metadata" do
177177
quietly { db_tasks.dump_schema_cache connection, filename }
178178

179-
schema_cache = YAML.load(File.read(filename))
179+
filedata = File.read(filename)
180+
schema_cache = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(filedata) : YAML.load(filedata)
180181

181182
col_id, col_name = connection.schema_cache.columns("users")
182183

0 commit comments

Comments
 (0)