未验证 提交 26a50081 编写于 作者: R Rafael França 提交者: GitHub

Revert "Deprecate YAML loading from legacy format older than Rails 5.0"

上级 0601a9f9
* Deprecate YAML loading from legacy format older than Rails 5.0.
*Ryuta Kamizono*
* Added the setting `ActiveRecord::Base.immutable_strings_by_default`, which
allows you to specify that all string columns should be frozen unless
otherwise specified. This will reduce memory pressure for applications which
......
# frozen_string_literal: true
module ActiveRecord
module LegacyYamlAdapter # :nodoc:
module LegacyYamlAdapter
def self.convert(klass, coder)
return coder unless coder.is_a?(Psych::Coder)
case coder["active_record_yaml_version"]
when 1, 2 then coder
else
ActiveSupport::Deprecation.warn(<<-MSG.squish)
YAML loading from legacy format older than Rails 5.0 is deprecated
and will be removed in Rails 6.2.
MSG
if coder["attributes"].is_a?(ActiveModel::AttributeSet)
Rails420.convert(klass, coder)
else
......@@ -20,7 +16,7 @@ def self.convert(klass, coder)
end
end
module Rails420 # :nodoc:
module Rails420
def self.convert(klass, coder)
attribute_set = coder["attributes"]
......@@ -36,7 +32,7 @@ def self.convert(klass, coder)
end
end
module Rails41 # :nodoc:
module Rails41
def self.convert(klass, coder)
attributes = klass.attributes_builder
.build_from_database(coder["attributes"])
......
......@@ -94,9 +94,7 @@ def test_a_yaml_version_is_provided_for_future_backwards_compat
end
def test_deserializing_rails_41_yaml
topic = assert_deprecated do
YAML.load(yaml_fixture("rails_4_1"))
end
topic = YAML.load(yaml_fixture("rails_4_1"))
assert_predicate topic, :new_record?
assert_nil topic.id
......@@ -105,9 +103,7 @@ def test_deserializing_rails_41_yaml
end
def test_deserializing_rails_4_2_0_yaml
topic = assert_deprecated do
YAML.load(yaml_fixture("rails_4_2_0"))
end
topic = YAML.load(yaml_fixture("rails_4_2_0"))
assert_not_predicate topic, :new_record?
assert_equal 1, topic.id
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册