Repository navigation
Allow retain_unlisted_types_on_load: :all - #144
Open
themiguelamador wants to merge 1 commit into
Open
themiguelamador wants to merge 1 commit into
themiguelamador wants to merge 1 commit into
Conversation
`:retain_unlisted_types_on_load` takes a list of type names to load as raw maps instead of raising. `:all` retains every type the field does not know, for types a codebase cannot list in advance: several application versions sharing a database during a rolling deploy (a newer release writes a type the older one does not ship), or a type removed without migrating its rows. Known types still load as their structs, and a list keeps its current meaning. Closes mathieuprog#142.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #142.
:retain_unlisted_types_on_loadtakes a list of type names that load as raw maps instead of raising. This PR also accepts:all, which retains every type the field doesn't know. That covers types a codebase can't list in advance:Behaviour
:all: any type not intypesloads as the raw map. Known types still load as their structs.:allor a list of atoms, and its error message says so.:all, and notes that a retained raw map can't be dumped back, so such records are read-only.Tests
Four tests on
PolymorphicEmbed.load/3::allloads unknown types as raw maps;:allstill loads a known type as its struct;The first, second and fourth fail without the change.
mix test: 81 passed, on Elixir 1.20.3 / OTP 28.We've been running this exact patch in production (vendored 5.0.6) to keep reads alive across deploys.