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

Add check if value is frozen before attempting to mutate via encode! #5209

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ def type_cast(value, column) # :nodoc:
value = super value = super
if column.type == :string && value.encoding == Encoding::ASCII_8BIT if column.type == :string && value.encoding == Encoding::ASCII_8BIT
@logger.error "Binary data inserted for `string` type on column `#{column.name}`" @logger.error "Binary data inserted for `string` type on column `#{column.name}`"
value.encode! 'utf-8' if value.frozen?
value = value.dup.encode! 'utf-8'
elsif
value.encode! 'utf-8'
end
end end
value value
end end
Expand Down