Commit 6b705dbf by Mickael Gerard

Handle array column limits

if column limit is an array, the values are serialilzed into column attr cf enum_column3 gem
parent 8bd159c7
......@@ -120,7 +120,11 @@ module AnnotateModels
col_type << "(#{col.precision}, #{col.scale})"
else
if (col.limit)
col_type << "(#{col.limit})" unless NO_LIMIT_COL_TYPES.include?(col_type)
if col.limit.is_a? Array
attrs << "(#{col.limit.join(', ')})"
else
col_type << "(#{col.limit})" unless NO_LIMIT_COL_TYPES.include?(col_type)
end
end
end
......
......@@ -91,6 +91,23 @@ EOS
EOS
end
it "should get schema info with enum type " do
klass = mock_class(:users, nil, [
mock_column(:id, :integer),
mock_column(:name, :enum, :limit => [:enum1, :enum2])
])
AnnotateModels.get_schema_info(klass, "Schema Info").should eql(<<-EOS)
# Schema Info
#
# Table name: users
#
# id :integer not null
# name :enum not null, (enum1, enum2)
#
EOS
end
it "should get schema info as RDoc" do
klass = mock_class(:users, :id, [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment