Skip to content

fix: support column with Unicode comment #911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

ota42y
Copy link

@ota42y ota42y commented Dec 15, 2021

When we crete column with Unicode comment, annotate gem does not update that annotation.

\w means a word character([a-zA-Z0-9_]) and it does not match Unicode leteers.
https://docs.ruby-lang.org/en/3.0.0/Regexp.html

Now column_pattern in annotante_one_file support
ascii characters only and doesn't match column with unicode comment.
So the columns will disappear from old_columns and new_columns.

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

Even if we change that column (i.e. nullable to not null),
annotate_one_file's check ignore that column so annotation doesn't update.
(The first time create it, it works, and the column annotation is left out of date)

So I fix column_pattern support Unicode letter.

@ota42y ota42y force-pushed the feautre/support_unicode_comment branch from bcebad0 to a2a5041 Compare December 15, 2021 11:44
@ctran ctran added the bug label Feb 3, 2022
@ctran ctran changed the title bugfix update column with Unicode comment fix: support column with Unicode comment Feb 3, 2022
@ctran ctran added this to the v3.2.0 milestone Feb 3, 2022
Copy link
Owner

@ctran ctran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm not sure why the "ci" build didn't get triggered?

@ctran ctran self-assigned this Feb 3, 2022
@ctran ctran closed this Feb 3, 2022
@ctran ctran reopened this Feb 3, 2022
@ctran ctran modified the milestones: v3.2.0, v3.2.1 Mar 8, 2022
@ota42y ota42y force-pushed the feautre/support_unicode_comment branch from 8a73b95 to 518badc Compare April 21, 2022 08:48
ota42y added 2 commits April 21, 2022 17:49
When we crete column with unicode comment, annotate gem does not update that annotation.

`\w` means a word character([a-zA-Z0-9_]) and it does not match unicode
leteers.
https://docs.ruby-lang.org/en/3.0.0/Regexp.html

Now `column_pattern` in `annotante_one_file` support
ascii characters only and doesn't match column with unicode comment.
So the columns will disappear from `old_columns` and `new_columns`.

https://github.com/ctran/annotate_models/blob/786394947c041f781df2ee0ea003e09452fa9dba/lib/annotate/annotate_models.rb#L378-L380

Even if we change that column (i.e. nullable to not null),
annotate_one_file's check ignore that column so annotation doesn't
update.
(The first time create it, it works, and the column annotation is left out of date)

So I fix column_pattern support unicode letter.

Signed-off-by: ota42y <ota42y@gmail.com>
Signed-off-by: ota42y <ota42y@gmail.com>
@ota42y ota42y force-pushed the feautre/support_unicode_comment branch from 518badc to a96e20c Compare April 21, 2022 08:49
@ota42y ota42y requested a review from ctran April 21, 2022 08:54
@ota42y
Copy link
Author

ota42y commented Apr 21, 2022

I fixed rubocop warning and these test failed occurred in develop branch so I think this change is no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants