You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Setting an enum attribute to nil fails with “Cannot determine type for nil values” #452
The update raises Cannot determine type for nil values, and the record isn’t saved. Setting the attribute to a non-nil value works.
Expected: the column is set to NULL.
In case this is helpful, here's some more info from when I dug into the issue:
Cause
SpannerActiveRecordConverter.convert_active_model_type_to_spanner doesn’t recognize ActiveRecord::Enum::EnumType. That type isn’t in TYPE_MAP and isn’t handled in fallback_convert_active_model_type_to_spanner, so the method returns nil. The bind is then sent without a type, and the client library infers one from the value. That works for a string but not for nil.
Suggested fix
Unwrap the enum to its underlying column type before the lookup, the same way DelegateClass types are unwrapped now:
def self.convert_active_model_type_to_spanner type
return nil if type.nil?
type = type.__getobj__ if type.respond_to? :__getobj__
type = type.subtype if type.is_a? ActiveRecord::Enum::EnumType
TYPE_MAP[type.class] || fallback_convert_active_model_type_to_spanner(type)
end
Activity
amy-found commentedon Nov 6, 2026
In case this is helpful, here's some more info from when I dug into the issue:
Cause
SpannerActiveRecordConverter.convert_active_model_type_to_spanner doesn’t recognize ActiveRecord::Enum::EnumType. That type isn’t in TYPE_MAP and isn’t handled in fallback_convert_active_model_type_to_spanner, so the method returns nil. The bind is then sent without a type, and the client library infers one from the value. That works for a string but not for nil.
Suggested fix
Unwrap the enum to its underlying column type before the lookup, the same way DelegateClass types are unwrapped now: