Nested Embeds
barnabasj:
Hi,
I’m trying to create a resource with nested Embeds
e.g.
:embed TimeRange
attributes do
attribute :start, :time
attribute :end, :time
end
:embed Checkin
attributes
attribute schedule: TimeRange
attribute ...
end
:postgres Hotel
attributes do
attribute :checkin, Checkin
...
end
But it seems Ecto cannot load structures like this If I understood this Issue https://github.com/elixir-ecto/ecto/issues/1256 correctly.
Is this just a limitation we have to live with?
barnabasj:
This also means types like
time
do not work in embbeded resources
ZachDaniel:
So, are you seeing issues around this with your Ash embeds? We don’t use ecto’s embed logic, we use regular types to back embeds:
def storage_type, do: :map
And then when we load them we load the nested values.
ZachDaniel:
So we ought to be able to have nested embeds/support loading whatever types when using Ash embedded resources.
barnabasj:
I used ecto directly to bulk insert the values, but used the regular Ash Api to read the values and I got an ecto issue. Knowing that it should be possible, I’ll try again and, see if I can figure out what the problem is.
ZachDaniel:
Will close this for now, but feel free to reopen if you determine that its definitely an Ash issue.