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

Add caveat about normalizes / Marshal interaction [ci-skip] #49876

Conversation

jonathanhefner
Copy link
Member

When ActiveRecord.marshalling_format_version is set to 6.1, Marshal will try to serialize attribute types along with the model, causing a TypeError if the model uses ActiveRecord::Base.normalizes with a normalization Proc.

This commit adds a caveat to the normalizes API documentation to warn users that they should set marshalling_format_version to 7.1 if they are using normalizes and marshalling the targeted model.

Fixes #49871.


@mjankowski Do you feel like this would have prevented the issue you encountered?

When `ActiveRecord.marshalling_format_version` is set to `6.1`,
`Marshal` will try to serialize attribute types along with the model,
causing a `TypeError` if the model uses `ActiveRecord::Base.normalizes`
with a normalization `Proc`.

This commit adds a caveat to the `normalizes` API documentation to warn
users that they should set `marshalling_format_version` to `7.1` if they
are using `normalizes` and marshalling the targeted model.

Fixes rails#49871.
@mjankowski
Copy link
Contributor

@mjankowski Do you feel like this would have prevented the issue you encountered?

Maybe not prevented, but definitely helped diagnose. I think this is useful.

@jonathanhefner jonathanhefner merged commit 6cf3f6d into rails:main Nov 1, 2023
3 checks passed
@jonathanhefner
Copy link
Member Author

jonathanhefner commented Nov 1, 2023

Ok, we'll go with this for now then. Thank you for the feedback, @mjankowski! 😃

Backported to 7-1-stable in 34c77a9.

jonathanhefner added a commit that referenced this pull request Nov 1, 2023
…s-marshalling_format_version-caveat

Add caveat about `normalizes` / `Marshal` interaction [ci-skip]

(cherry picked from commit 6cf3f6d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Usage of normalizes interacting with caching/dumping
2 participants