From a9c0fb62ecb14c2add17da9e7450272b8f0830ad Mon Sep 17 00:00:00 2001 From: lcp Date: Mon, 25 May 2015 13:00:06 +0800 Subject: [PATCH] ignore default value for jsonb --- lib/annotate/annotate_models.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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"