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

ActiveRecord::Base.serialize signature changed when ActiveRecord >= 7.1 #383

Closed
azhaizhai opened this issue Dec 25, 2023 · 1 comment
Closed
Assignees

Comments

@azhaizhai
Copy link

ActiveRecord::Base.serialize changed the signature in 7.1.0beta1 https://github.com/rails/rails/blob/7-1-stable/activerecord/CHANGELOG.md
image
Here is no longer compatibility in rails 7.1.0+

serialize :parameters, Hash unless %i[json jsonb hstore].include?(columns_hash['parameters'].type)

Maybe we can change it to

if Rails.version >= '7.1.0'
  serialize :parameters, type: Hash unless %i[json jsonb hstore].include?(columns_hash['parameters'].type)
else
  serialize :parameters,  Hash unless %i[json jsonb hstore].include?(columns_hash['parameters'].type)
end
rickbenavidez added a commit to rickbenavidez/public_activity that referenced this issue Dec 27, 2023
@ur5us ur5us self-assigned this Jan 15, 2024
@ur5us
Copy link
Collaborator

ur5us commented Jan 15, 2024

@azhaizhai Technically Rails 7.1 still support the old signature, s. https://github.com/rails/rails/blob/v7.1.2/activerecord/lib/active_record/attribute_methods/serialization.rb#L183

def serialize(attr_name, class_name_or_coder = nil, coder: nil, type: Object, yaml: {}, **options)

The incompatibility with Rails 7.1 stems from a different issue, i.e. the lack of a default coder which is the breaking change. Going forward, we will explicitly define a coder.

Closing this in favor of #382.

@ur5us ur5us closed this as completed Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants