提交 540a8185 编写于 作者: R Rafael Mendonça França

Merge pull request #18307 from brainopia/datetime_regression

Fully support datetime values in AR::Type::DateTime#type_cast_for_database
......@@ -11,7 +11,11 @@ def type_cast_for_database(value)
zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal
if value.acts_like?(:time)
value.send(zone_conversion_method)
if value.respond_to?(zone_conversion_method)
value.send(zone_conversion_method)
else
value
end
else
super
end
......
......@@ -50,4 +50,12 @@ def test_assign_empty_time
topic.bonus_time = ''
assert_nil topic.bonus_time
end
def test_assign_in_local_timezone
now = DateTime.now
with_timezone_config default: :local do
task = Task.new starting: now
assert now, task.starting
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册