Commit 674e7806 by Cuong Tran

Merge pull request #115 from tableonline/handle_column_limit_with_arrays

Handle array column limits
parents 1d966425 6b705dbf
...@@ -120,9 +120,13 @@ module AnnotateModels ...@@ -120,9 +120,13 @@ module AnnotateModels
col_type << "(#{col.precision}, #{col.scale})" col_type << "(#{col.precision}, #{col.scale})"
else else
if (col.limit) if (col.limit)
if col.limit.is_a? Array
attrs << "(#{col.limit.join(', ')})"
else
col_type << "(#{col.limit})" unless NO_LIMIT_COL_TYPES.include?(col_type) col_type << "(#{col.limit})" unless NO_LIMIT_COL_TYPES.include?(col_type)
end end
end end
end
# Check out if we got a geometric column # Check out if we got a geometric column
# and print the type and SRID # and print the type and SRID
......
...@@ -92,6 +92,23 @@ EOS ...@@ -92,6 +92,23 @@ EOS
EOS EOS
end 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 it "should get schema info as RDoc" do
klass = mock_class(:users, :id, [ 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