From 067ce522944590351f7bc8ed6bfbf74f672a9562 Mon Sep 17 00:00:00 2001 From: Ilya Vassilevsky Date: Thu, 19 Feb 2015 10:40:56 +0300 Subject: [PATCH] Prefer SQL column type over normalized AR type --- lib/annotate/annotate_models.rb | 2 +- spec/annotate/annotate_models_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/annotate/annotate_models.rb b/lib/annotate/annotate_models.rb index 01cd5c82b..65c295795 100644 --- a/lib/annotate/annotate_models.rb +++ b/lib/annotate/annotate_models.rb @@ -140,7 +140,7 @@ def get_schema_info(klass, header, options = {}) 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 + col_type = (col.sql_type || col.type).to_s if col_type == "decimal" col_type << "(#{col.precision}, #{col.scale})" elsif col_type != "spatial" diff --git a/spec/annotate/annotate_models_spec.rb b/spec/annotate/annotate_models_spec.rb index 76d60f216..81cc993cd 100755 --- a/spec/annotate/annotate_models_spec.rb +++ b/spec/annotate/annotate_models_spec.rb @@ -28,7 +28,7 @@ def mock_column(name, type, options={}) stubs = default_options.dup stubs.merge!(options) - stubs.merge!(:name => name, :type => type) + stubs.merge!(:name => name, :sql_type => type, :type => type) double("Column", stubs) end