annotate_models icon indicating copy to clipboard operation
annotate_models copied to clipboard

Inconsistent types in db/structure.sql and annotations

Open mainameiz opened this issue 6 years ago • 0 comments

Some columns in my project has bigint type. In db/structure.sql these columns has type bigiint(20), but in annotations they has bigint(8).

Line from db/structure.sql:

  `id` bigint(20) NOT NULL AUTO_INCREMENT,

Line from annotations:

#  id               :bigint(8)        not null, primary key

I investigate the following:

From: /home/nmarkov/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/annotate-2.7.4/lib/annotate/annotate_models.rb @ line 256 AnnotateModels.get_schema_info:

    251:         if klass == GlacierArchive
    252:           if col.name == 'id'
    253:             require 'pry'
    254:             binding.pry
    255:           end
 => 256:           puts col.name.inspect
    257:           puts col_type.inspect
    258:         end
    259:         attrs = []
    260:         attrs << "default(#{schema_default(klass, col)})" unless col.default.nil? || hide_default?(col_type, options)
    261:         attrs << 'unsigned' if col.respond_to?(:unsigned?) && col.unsigned?

[1] pry(AnnotateModels)> 
[2] pry(AnnotateModels)> col
=> #<ActiveRecord::ConnectionAdapters::MySQL::Column:0x0000564812826738
 @collation=nil,
 @comment=nil,
 @default=nil,
 @default_function=nil,
 @name="id",
 @null=false,
 @sql_type_metadata=#<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x0000564812826c10 @limit=8, @precision=nil, @scale=nil, @sql_type="bigint(20)", @type=:integer>,
 @table_name="glacier_archives">

@limit=8 @sql_type="bigint(20)"

@limit=8 is used in annotations.

Version

  • annotate version - 2.7.4
  • rails version 5.1.7
  • ruby version - 2.5.1

Is it a bug?

mainameiz avatar Jul 23 '19 09:07 mainameiz