ctran / annotate_models

Annotate Rails classes with schema and routes info
Other
4.41k stars 600 forks source link

Comments by multi-byte characters are ignored #836

Open a-suenami opened 4 years ago

a-suenami commented 4 years ago

Hi, everyone. So thank you for great product.

I occurred in trouble and want to hear everyone's opinion.

I'm Japanese developer so often add some comment for each database column in Japanese.

For example:

create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci", comment: "ユーザ", force: :cascade do |t|
  t.string "name", null: false, comment: "名前"
  t.string "email", null: false, comment: "メールアドレス"
end

However, they're ignored because they don't match a regular expression which checks diff between old schema and new schema, It's specified here.

If we don't have any problems, I want to fix the problem as follows.

# current
column_pattern = /^#[\t ]+[\w\*\.`]+[\t ]+.+$/

# I expect
column_pattern = /^#[\t ]+[^\t ]+[\t ]+.+$/

What do you think?

Commands

$ bundle exec annotate
Model files unchanged.

Version

younthu commented 3 years ago

Same here

igaiga commented 3 years ago

Same here

tkfric commented 1 year ago

Same here

jmatsu commented 6 months ago

This still happens on HEAD of develop branch (i.e. https://github.com/ctran/annotate_models/commit/5d01c4171990c4fe7b9b0977b05ce14a98209e53), so we've switched to with_comment_column style instead of with_comment. It works great even if a comment includes any cause character like multi-byte characters. I hope this will help you.