Skip to content

Commit 067ce52

Browse files
vassilevskyIlya Vassilevsky
authored and
Ilya Vassilevsky
committed
Prefer SQL column type over normalized AR type
1 parent f3d9ad5 commit 067ce52

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/annotate/annotate_models.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def get_schema_info(klass, header, options = {})
140140
attrs << "not null" unless col.null
141141
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)
142142

143-
col_type = (col.type || col.sql_type).to_s
143+
col_type = (col.sql_type || col.type).to_s
144144
if col_type == "decimal"
145145
col_type << "(#{col.precision}, #{col.scale})"
146146
elsif col_type != "spatial"

spec/annotate/annotate_models_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def mock_column(name, type, options={})
2828

2929
stubs = default_options.dup
3030
stubs.merge!(options)
31-
stubs.merge!(:name => name, :type => type)
31+
stubs.merge!(:name => name, :sql_type => type, :type => type)
3232

3333
double("Column", stubs)
3434
end

0 commit comments

Comments
 (0)