Skip to content

Commit 98c182e

Browse files
committed
Merge pull request #250 from LcpMarvel/develop
ignore default value for jsonb
2 parents be6f088 + a9c0fb6 commit 98c182e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/annotate/annotate_models.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ def get_schema_info(klass, header, options = {})
138138
cols = cols.sort_by(&:name) if(options[:sort])
139139
cols = classified_sort(cols) if(options[:classified_sort])
140140
cols.each do |col|
141+
col_type = (col.type || col.sql_type).to_s
142+
141143
attrs = []
142-
attrs << "default(#{schema_default(klass, col)})" unless col.default.nil?
144+
attrs << "default(#{schema_default(klass, col)})" unless col.default.nil? || col_type == "jsonb"
143145
attrs << "not null" unless col.null
144146
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)
145147

146-
col_type = (col.type || col.sql_type).to_s
147148
if col_type == "decimal"
148149
col_type << "(#{col.precision}, #{col.scale})"
149150
elsif col_type != "spatial"

0 commit comments

Comments
 (0)