Search code examples
erlangelixirecto

Why insert_all does not work with changesets?


Does someone know, what is the limitation in Ecto that the insert all is not made to be working with changesets? Usually I need to create change sets for all entries and then map them to normal map(at the same time removing the virtual fields if existing and the not loaded entities).


Solution

  • Repo.insert_all can not insert into multiple tables. Since changesets can do, e.g. cast_assoc to create/update/delete multiple associations, this conflicts with the way bulk inserts work.

    Can you describe your data model, so it will be easier to talk about possible approaches to achieve what you want?