Skip to content

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