We use types inheriting from ActiveModel::Type::Value where the deserialize sig says it returns T.nilable([custom type]). However when using the new dsl persisted mode, we can assume the type won't be nilable.
Implementation
Apply as_non_nilable_type to getter_type and setter_type only in persisted mode and when the column is not nullable.
Motivation
We use types inheriting from
ActiveModel::Type::Value
where thedeserialize
sig says it returnsT.nilable([custom type])
. However when using the new dslpersisted
mode, we can assume the type won't be nilable.Implementation
Apply
as_non_nilable_type
togetter_type
andsetter_type
only in persisted mode and when the column is not nullable.Tests
I've added tests.