Skip to content

Support associations inside embeds #1837

Closed

Description

@michalmuskala

When embeds were introduced it was never considered that an association could be inside an embed. Because of this, it silently fails.

There are couple places where changes are needed:

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.

Activity

  1. jfayad commented on Dec 8, 2016

    @jfayad

    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

  2. michalmuskala commented on Dec 8, 2016

    @michalmuskala
    MemberAuthor

    Embeds inside embeds should work correctly. This is a use case that is extensively tested.

  3. merqlove commented on Feb 15, 2017

    @merqlove

    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

  4. merqlove commented on Feb 15, 2017

    @merqlove

    Aha, i found workaround for embeds :)
    Repo.preload(pts, :party, prefix: nil)

  5. josevalim commented on May 18, 2017

    @josevalim
    Member

    I am closing this for now. If someone is interested on this feature, a pull request is welcome!

  6. linjunpop commented on May 27, 2019

    @linjunpop
    Contributor

    +1 for associations inside embeds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions