Skip to content
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

Allow running annotate for when the columns are frozen #1030

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

Conversation

ignacio-chiazzo
Copy link

@ignacio-chiazzo ignacio-chiazzo commented Sep 4, 2024

Edit: I noticed that it was fixed in a newer version 🤦 (PR #895). I left the PR open in case you want the tests.

In case where the columns are frozen, the gem 💥 when annotating the models:

col = MyModel.columns.map { |n| [n.name, n.frozen?] } # => [[a, true], [b, true], [c, true]]
col.frozen? #=> true
col.type.to_s.frozen? # => true

The problem is that we're trying to modify the string when doing column_type << ... in lines:

if column_type == 'decimal'
column_type << "(#{column.precision}, #{column.scale})"
elsif !%w[spatial geometry geography].include?(column_type)
if column.limit && !options[:format_yard]
if column.limit.is_a? Array
attrs << "(#{column.limit.join(', ')})"
else
column_type << "(#{column.limit})" unless hide_limit?(column_type, options)
end
end
end

The fix

I duplicated the value if it's frozen 95327bd#diff-60ea710bcc08132bf411088124fcaa2b569a5ac493a5d364e0141f425afe2477R943

@ctran ctran self-assigned this Sep 16, 2024
@ctran ctran added this to the v3.2.1 milestone Sep 16, 2024
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.

2 participants