Skip to content

Conversation

@sashabelozerov
Copy link
Contributor

Fixes #570

new_header = info_block.match(header_pattern).to_s

column_pattern = /^#[\t ]+[\w\*`]+[\t ]+.+$/
column_pattern = /^#[\t ]+[\w\*\.`]+[\t ]+.+$/
Copy link
Owner

Choose a reason for hiding this comment

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

Could you leave a note as to why this would fix the problem?

Copy link
Contributor Author

@sashabelozerov sashabelozerov Dec 15, 2019

Choose a reason for hiding this comment

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

@ctran Line with a foreign key info in an annotation text looks like:

# fk_rails_... (foreign_thing_id => foreign_things.id) ON DELETE => restrict

It didn't match the previous pattern because of dots at the end of the foreign key name (we have dots there because we truncate generated foreign key names at https://github.com/ctran/annotate_models/blob/develop/lib/annotate/annotate_models.rb#L477).

In turn, because a foreign key line didn't match the pattern, we didn't check it for changes at https://github.com/ctran/annotate_models/blob/develop/lib/annotate/annotate_models.rb#L525

Changes in the pattern solves this case.

Hope this helps.

Copy link
Owner

Choose a reason for hiding this comment

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

Does it mean if the name doesn't end with "...", this pattern won't match anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ctran No. [\w\*\.`] - this part of the regexp represents characters which a name can consist of, in any order. It will match both names with "..." and without them.

@ctran ctran added this to the v3.1.0 milestone Dec 18, 2019
@ctran ctran merged commit 5219c7e into ctran:develop Dec 18, 2019
@ctran
Copy link
Owner

ctran commented Dec 18, 2019

Thanks!

peterfication pushed a commit to store2be/annotate_models that referenced this pull request Jan 20, 2020
vfonic pushed a commit to vfonic/annotate_models that referenced this pull request May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

foreign key change of type don't get noticed

2 participants