Skip to content

Conversation

@seanpdoyle
Copy link
Contributor

Follow-up to #420

Problem

While the Coder class and Serialization module aim to comply with Active Record, there's still potential for that compatibility to drift of break without sufficient test coverage.

The Coder#load implementation does not support inferring the correct @persisted value from payloads with root-level keys. For example, { "person": { "id": 1 } } will not be inferred as persisted in the same way that { "id": 1 } will.

Proposal

To resolve the @persisted value, call Format.remove_root to ensure that the payload consists of only attributes.

Follow-up to [rails#420][]

Problem
---

While the `Coder` class and `Serialization` module aim to comply with
Active Record, there's still potential for that compatibility to drift
of break without sufficient test coverage.

The `Coder#load` implementation does not support inferring the correct
`@persisted` value from payloads with root-level keys. For example, `{
"person": { "id": 1 } }` will not be inferred as persisted in the same
way that `{ "id": 1 }` will.

Proposal
---

To resolve the `@persisted` value, call `Format.remove_root` to ensure
that the payload consists of only attributes.

[rails#420]: rails#420
@rafaelfranca rafaelfranca merged commit b21bec6 into rails:main Oct 1, 2025
19 checks passed
@seanpdoyle seanpdoyle deleted the coder-remove-root branch October 1, 2025 20:51
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

Successfully merging this pull request may close these issues.

2 participants