-
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
Added Repo.embedded_load/3 function #3270
Added Repo.embedded_load/3 function #3270
Conversation
as described in elixir-ecto#3269
Oh, interesting. Given this function doesn't use the adapter, maybe it doesn't belong on Repo but elsewhere. The question is where? |
Btw, really good job. The question is only where to place the code. |
Yeah that's true. I think it belongs in Schema then. |
@wojtekmach @michalmuskala any thoughts? |
Yeah, neither option seems optimal to me. Given embedded_load/3 is implemented and documented almost identically to Repo.load/2, I think I'd keep it on the Repo regardless of the caveat you mentioned (which I totally agree with). I think putting it on |
Yes, I agree. We'll need at least a lot of cross-linking between them since they are related. I think there's another question and that is loading data that is not from database into the schema. Since, as far as I remember, for embeds load and cast is exactly the same this is generally already possible with |
One advantage over the changeset calls is that you don't need to repeat the list of fields. The changeset approach offers more flexibility of course. |
Good call. In those cases we may not have a repo, so putting it on a repo is a no-go. I looked at Ecto.Schema and it only has the schema definition functionality, functions that work on the schema at runtime are all in Ecto, so I propose to add it as Can you please amend it acccordingly @narrowtux ? Thanks everyone! |
Okay |
@josevalim I moved the embedded_load/3 function to the Ecto module, and moved the test to |
💚 💙 💜 💛 ❤️ |
It feels like Ecto.embedded_dump/3 would really complement this feature, but this is good enough for getting started. Thanks @narrowtux ! |
Yeah, an |
Also, I noticed that this function doesn't load the data into recursive schemas. I'll continue to work on this a bit |
as described in #3269