ctran/annotate_models

add new_column with chinese comment would cause skip annotate_one_file

lyb124553153 opened this issue · 1 comments

column_pattern = /^#[\t ]+[\w\*\.`]+[\t ]+.+$/
old_columns = old_header && old_header.scan(column_pattern).sort
new_columns = new_header && new_header.scan(column_pattern).sort
return false if old_columns == new_columns && !options[:force]

Commands

str = "# Table name: foos\n" +
"#\n" +
"#  id                                    :bigint(8)        not null, primary key\n" +
"# test(测试)                       :decimal(, )      not null\n" 
column_pattern = /^#[\t ]+[\w\*\.`]+[\t ]+.+$/ 

columns = str.scan(column_pattern) # expect 3 column only get 2 seems test doesnt match column_pattern
 

Version

  • annotate version v3.1.1
  • rails version v5.2
  • ruby version v2.7.2

Hey lyb124553153,

After running into many problems with annotate myself, I have developed the gem datagaze which fixes those issues.

I expect that the gem might also resolve your issue. Would you like to try it out, and let me know if it has solved your problem?

The gem is to be found at: https://github.com/jurriaanschrofer/datagaze.

Background story of the gem: annotate's lookup system is often rigid and based on very strict conventions. Instead, I have devised a more dynamic way of annotating, through the use of ruby's const_source_location method and rails' ApplicationRecord.descendants.