Skip to content

Commit a9c0fb6

Browse files
author
lcp
committed
ignore default value for jsonb
1 parent ce188d3 commit a9c0fb6

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
@@ -135,12 +135,13 @@ def get_schema_info(klass, header, options = {})
135135
cols = cols.sort_by(&:name) if(options[:sort])
136136
cols = classified_sort(cols) if(options[:classified_sort])
137137
cols.each do |col|
138+
col_type = (col.type || col.sql_type).to_s
139+
138140
attrs = []
139-
attrs << "default(#{schema_default(klass, col)})" unless col.default.nil?
141+
attrs << "default(#{schema_default(klass, col)})" unless col.default.nil? || col_type == "jsonb"
140142
attrs << "not null" unless col.null
141143
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)
142144

143-
col_type = (col.type || col.sql_type).to_s
144145
if col_type == "decimal"
145146
col_type << "(#{col.precision}, #{col.scale})"
146147
elsif col_type != "spatial"

0 commit comments

Comments
 (0)