tpitale
INSERT … SELECT in Ecto using Ecto.Query
I’m attempting to replicate an INSERT … SELECT in Ecto. This appears to be supported by both postgres and mysql (I’m using postgres). I’ve got this working in SQL, but trying to recreate in Ecto.Query.
I created an ecto query that returns the data I want, and tried passing it to insert or insert_all and both seemed to cause errors.
Is there a supported method to do this, or is the official answer, “just use sql”?
I found this post that didn’t really answer the question from Aug 2018: Execute Insert_all from a select
Marked As Solved
cpgo
Since this reply still getting lots of clicks and this thread is the top result on google I’ll post an update here.
José pointed out on the last PR I linked that there is a new feature that might address this feature.
https://hexdocs.pm/ecto/Ecto.Repo.html#c:insert_all/3-source-query







