diff --git a/lib/annotate/annotate_models.rb b/lib/annotate/annotate_models.rb index b21520c63..7af32f7c8 100644 --- a/lib/annotate/annotate_models.rb +++ b/lib/annotate/annotate_models.rb @@ -135,12 +135,13 @@ def get_schema_info(klass, header, options = {}) cols = cols.sort_by(&:name) if(options[:sort]) cols = classified_sort(cols) if(options[:classified_sort]) cols.each do |col| + col_type = (col.type || col.sql_type).to_s + attrs = [] - attrs << "default(#{schema_default(klass, col)})" unless col.default.nil? + attrs << "default(#{schema_default(klass, col)})" unless col.default.nil? || col_type == "jsonb" attrs << "not null" unless col.null attrs << "primary key" if klass.primary_key && (klass.primary_key.is_a?(Array) ? klass.primary_key.collect{|c|c.to_sym}.include?(col.name.to_sym) : col.name.to_sym == klass.primary_key.to_sym) - col_type = (col.type || col.sql_type).to_s if col_type == "decimal" col_type << "(#{col.precision}, #{col.scale})" elsif col_type != "spatial"