You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While it makes little sense to use associations inside embeds in SQL databases, the main use case would be in various NoSQL ones, where this seems like a completely reasonable thing to do.
Reacted by Alexander Merkulov, Kelvin Stinghen, Murtza, Matias Ibañez, John Lanz, joelevering and Adrian Fraiha
Reacted by Jun Lin, Adrian Fraiha and T. Floyd Wright
I would also add that embeds should also work inside an embed.
I think this type of recursion shouldn't be limited by Ecto because each design is not right or wrong it always depends on how it will be used at max show a warning if the recursion is really going deep
Activity
jfayad commentedon Dec 8, 2016
I would also add that embeds should also work inside an embed.
I think this type of recursion shouldn't be limited by Ecto because each design is not right or wrong it always depends on how it will be used at max show a warning if the recursion is really going deep
michalmuskala commentedon Dec 8, 2016
Embeds inside embeds should work correctly. This is a use case that is extensively tested.
merqlove commentedon Feb 15, 2017
Looks likes it worked in version 1.0.0, because i'm have this pattern in my app & its tests. After upgrade to 2.0 this pattern is failed.
Example app which uses same pattern & fails on PG:
https://github.com/merqlove/some_ecto/blob/master/test/some_ecto_test.exs
merqlove commentedon Feb 15, 2017
Error is because embed structs don't have
__meta__.It was in 1.0:
https://github.com/elixir-ecto/ecto/blob/v1.0.0/lib/ecto/schema.ex#L319
But not in 2.0:
https://github.com/elixir-ecto/ecto/blob/v2.0/lib/ecto/schema.ex#L337
merqlove commentedon Feb 15, 2017
Aha, i found workaround for embeds :)
Repo.preload(pts, :party, prefix: nil)josevalim commentedon May 18, 2017
I am closing this for now. If someone is interested on this feature, a pull request is welcome!
linjunpop commentedon May 27, 2019
+1 for associations inside embeds.