Commit 55c23eb5 by Colby Melvin Committed by Andrew W. Lee

Fix annotations for columns with long data types (#622)

Handle potential negative padding in `#mb_chars_ljust` when having a `col_length` > 16, the default hardcoded value of `bare_type_allowance`.
parent b56e89df
...@@ -910,7 +910,11 @@ module AnnotateModels ...@@ -910,7 +910,11 @@ module AnnotateModels
def mb_chars_ljust(string, length) def mb_chars_ljust(string, length)
string = string.to_s string = string.to_s
padding = length - width(string) padding = length - width(string)
string + (' ' * padding) if padding > 0
string + (' ' * padding)
else
string[0..length-1]
end
end end
end end
......
...@@ -943,7 +943,8 @@ EOS ...@@ -943,7 +943,8 @@ EOS
[:active, :boolean, { limit: 1, comment: 'ACTIVE' }], [:active, :boolean, { limit: 1, comment: 'ACTIVE' }],
[:name, :string, { limit: 50, comment: 'NAME' }], [:name, :string, { limit: 50, comment: 'NAME' }],
[:notes, :text, { limit: 55, comment: 'NOTES' }], [:notes, :text, { limit: 55, comment: 'NOTES' }],
[:no_comment, :text, { limit: 20, comment: nil }] [:no_comment, :text, { limit: 20, comment: nil }],
[:location, :geometry_collection, { limit: nil, comment: nil }]
] ]
when_called_with with_comment: 'yes', when_called_with with_comment: 'yes',
...@@ -958,6 +959,7 @@ EOS ...@@ -958,6 +959,7 @@ EOS
# name(NAME) :string(50) not null # name(NAME) :string(50) not null
# notes(NOTES) :text(55) not null # notes(NOTES) :text(55) not null
# no_comment :text(20) not null # no_comment :text(20) not null
# location :geometry_collect not null
# #
EOS EOS
......
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