Conversation
References: - elixir-ecto#4398
|
It looks good to me, although I am a bit worried about loading virtual fields. Do you have thoughts @greg-rychlewski? Worst case scenario we require it to be opt-in via a flag. |
|
I think it would have to be opt-in because the function is shared by embedded loading. So if it wasn't opt-in virtual embed fields would start appearing in results. Using the schema as the type definition feels a bit off to me if wanting to load virtual fields. They are ignored in all the other Schema API functions, as far as I can see. Maybe it would make sense to expand the reflection api so the user can create their own type map? |
|
I looked into this again given there was a second request. The two main takeaways I see:
So I believe it's doable but probably a bigger change than anticipated. I think at minimum you have to add an optional 3rd field to the loaders callback in the adapter to conditionally apply virtuals. |
References:
Repo.load/2doesn't cast virtual fields into a Schema struct #4398