Commit 63cc88c1 by Shinichi Maeshima Committed by Cuong Tran

Annotate bigint columns as 'bigint' instead of 'integer' (#515)

parent 52757575
...@@ -249,7 +249,7 @@ module AnnotateModels ...@@ -249,7 +249,7 @@ module AnnotateModels
cols = cols.sort_by(&:name) if options[:sort] cols = cols.sort_by(&:name) if options[:sort]
cols = classified_sort(cols) if options[:classified_sort] cols = classified_sort(cols) if options[:classified_sort]
cols.each do |col| cols.each do |col|
col_type = (col.type || col.sql_type).to_s col_type = get_col_type(col)
attrs = [] attrs = []
attrs << "default(#{schema_default(klass, col)})" unless col.default.nil? || hide_default?(col_type, options) attrs << "default(#{schema_default(klass, col)})" unless col.default.nil? || hide_default?(col_type, options)
attrs << 'unsigned' if col.respond_to?(:unsigned?) && col.unsigned? attrs << 'unsigned' if col.respond_to?(:unsigned?) && col.unsigned?
...@@ -363,6 +363,14 @@ module AnnotateModels ...@@ -363,6 +363,14 @@ module AnnotateModels
index_info index_info
end end
def get_col_type(col)
if col.respond_to?(:bigint?) && col.bigint?
'bigint'
else
(col.type || col.sql_type).to_s
end
end
def index_columns_info(index) def index_columns_info(index)
Array(index.columns).map do |col| Array(index.columns).map do |col|
if index.try(:orders) && index.orders[col.to_s] if index.try(:orders) && index.orders[col.to_s]
......
...@@ -158,7 +158,7 @@ EOS ...@@ -158,7 +158,7 @@ EOS
[ [
mock_column(:id, :integer), mock_column(:id, :integer),
mock_column(:integer, :integer, unsigned?: true), mock_column(:integer, :integer, unsigned?: true),
mock_column(:bigint, :bigint, unsigned?: true), mock_column(:bigint, :integer, unsigned?: true, bigint?: true),
mock_column(:float, :float, unsigned?: true), mock_column(:float, :float, unsigned?: true),
mock_column(:decimal, :decimal, unsigned?: true, precision: 10, scale: 2), mock_column(:decimal, :decimal, unsigned?: true, precision: 10, scale: 2),
]) ])
......
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