`type_cast` is deprecated in activerecord 6.1.x
Closed this issue · 6 comments
It seems like the way we cast types for the ReplayOptimizedPostgresPersistor
is not reliable:
The type information for type casting is entirely separated to type
object, so if anyone does passing a column to `type_cast` in Rails 6,
they are likely doing something wrong. See the comment for more details:
From: rails/rails@92360e9
The column does not have sufficient type information if the user
provided a custom type on the class level either explicitly (via
Attributes::ClassMethods#attribute) or implicitly (via
AttributeMethods::Serialization::ClassMethods#serialize, +time_zone_aware_attributes+)
This is not really relevant for Sequent, but understand that this is deprecated. Any suggestions how to migrate this?
type_cast_from_column
warns against calling it directly on using it, but is available:
# If you are having to call this function, you are likely doing something
# wrong. The column does not have sufficient type information if the user
# provided a custom type on the class level either explicitly (via
# Attributes::ClassMethods#attribute) or implicitly (via
# AttributeMethods::Serialization::ClassMethods#serialize, +time_zone_aware_attributes+).
# In almost all cases, the sql type should only be used to change quoting behavior, when the primitive to
# represent the type doesn't sufficiently reflect the differences
# (varchar vs binary) for example. The type used to get this primitive
# should have been provided before reaching the connection adapter.
Okay, perhaps there is a a higher level type_cast_from_column
available which takes these possible custom types into account?
Just discussed this and the active_record_persistor
solves this nicely with Arel
. See #convert_to_values
in lib/sequent/core/persistors/active_record_persistor.rb
@stephanvd I think you resolved this right?