提交 65f11ff7 编写于 作者: A Aaron Patterson

column will use coder to typecase value when it is available

上级 a7c2f6be
......@@ -72,6 +72,8 @@ def klass
# Casts value (which is a String) to an appropriate instance.
def type_cast(value)
return nil if value.nil?
return coder.load(value) if encoded?
klass = self.class
case type
......
......@@ -24,6 +24,12 @@ def test_encoded?
assert column.encoded?
end
def test_type_case_coded_column
column = Column.new("title", nil, "varchar(20)")
column.coder = YAML
assert_equal "hello", column.type_cast("--- hello")
end
# Avoid column definitions in create table statements like:
# `title` varchar(255) DEFAULT NULL
def test_should_not_include_default_clause_when_default_is_null
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册