-
Notifications
You must be signed in to change notification settings - Fork 83
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
Replace 'type_cast_from_column' to support Rails 6.1 #68
Conversation
@mberlanda Does this seem like a reasonable change? I'm trying to upgrade a project to Rails 6.1 and it would be really helpful if we could release 1.8.2 with this change |
This patch works great on Rails 6.1.1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for the fix and sorry for the delay in the review. How did you test that this change is backward compatible? A part from that it looks good to me
value = @connection.type_cast_from_column(column, value) if column | ||
if column | ||
type = @connection.lookup_cast_type_from_column(column) | ||
value = type.serialize(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we confirm that this addition is backward compatible with Rails versions between 5 and 6.1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I run some tests locally and it seems to work.
value = @connection.type_cast_from_column(column, value) if column | ||
if column | ||
type = @connection.lookup_cast_type_from_column(column) | ||
value = type.serialize(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I run some tests locally and it seems to work.
Passing a column to the active_record method
type_cast
is deprecated and will be removed in Rails 6.2. Thetype_cast_from_column
method was also removed as part of Rails 6.1 in this PR. In the short term we can manually calllookup_cast_type_from_column
and serialize our values with the returned type.This resolves errors that look like the following, which occur when using
bulk_insert
and active_record6.1.X
, such as #67: