-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Repo.embedded_load/3 convenience #3269
Comments
A PR would be welcome! |
I can try, I'm stuck now anyway :D |
If you want to get unstuck, you can return this |
It was actually pretty easy, in def embedded_load(_adapter, schema_or_types, data, format) do
do_load(schema_or_types, data, &Ecto.Type.embedded_load(&1, &2, format))
end PR will follow shorltly |
narrowtux
added a commit
to narrowtux/ecto
that referenced
this issue
Apr 6, 2020
as described in elixir-ecto#3269
Closing in favor of PR! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I write queries that filter within embedded fields that are backed by JSON, I see no simple way to select the filtered embeds so they're correctly loaded using the ecto type system.
My example goes like this:
The
License
schema hasembeds_many :limits, Limit
which is backed by ajsonb
field.What I tried to load the resulting json documents into actual
%Limit{}
structs was to map the results through theRepo.load/2
function like this:However, since the primary key type is
Ecto.UUID
, it won't actually work withEcto.UUID.load
since that one expects a binary UUID and not a UUID in text form.So I propose a new convenience function
embedded_load(schema, data, format)
that usesEcto.Type.embedded_load/3
internally so I can fix my example like this:If there's any other way to prevent having to load manually I'd be glad to hear it :)
The text was updated successfully, but these errors were encountered: