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.
Ecto types can be so hard for me to wrap my head around sometimes, but I'm pretty sure this is right 😅
Here's an example from the docs with comments that I think are really helpful (I think they might be relatively new):
https://hexdocs.pm/ecto/Ecto.Type.html#module-example
But basically,
dump
takes what's on the Ecto schema struct and turns it into the database format. Socast
is to take potentially supported values (e.g. in forms) and turn them into the data type that's expected to be on the Ecto schema struct. Basicallyload
while is loading from the DB,cast
is kind of like "loading" from the outside world, and thus potentially needs to support different types of data.In that example in the docs, there should always be a
%URI{}
on the schema struct. Socast
takes strings and%URI{}
values and assigns them (I could imagine it also taking maps with the URL parts, depending on what you wanted to do).