提交 a7c2f6be 编写于 作者: A Aaron Patterson

coders can be assigned to columns

上级 6d5e3b86
......@@ -17,7 +17,9 @@ module Format
end
attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale
attr_accessor :primary
attr_accessor :primary, :coder
alias :encoded? :coder
# Instantiates a new column in the table.
#
......@@ -37,6 +39,7 @@ def initialize(name, default, sql_type = nil, null = true)
@type = simplified_type(sql_type)
@default = extract_default(default)
@primary = nil
@coder = nil
end
# Returns +true+ if the column is either of type string or text.
......
......@@ -10,6 +10,20 @@ def @adapter.native_database_types
end
end
def test_can_set_coder
column = Column.new("title", nil, "varchar(20)")
column.coder = YAML
assert_equal YAML, column.coder
end
def test_encoded?
column = Column.new("title", nil, "varchar(20)")
assert !column.encoded?
column.coder = YAML
assert column.encoded?
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.
先完成此消息的编辑!
想要评论请 注册