ycv005
Ecto query into Plain SQL
How to convert following Ecto Query into the Plain RAW SQL
%Workspace{name: "#{prefix() || "public"}"} |> Repo.insert()
Your response will be highly appreicable.
Most Liked
mxgrn
Wow, I just found GitHub - akoutmos/ecto_dbg: A utility to format and output Ecto queries · GitHub
It produces well-formatted, copy-paste-ready SQL right into my logs ![]()
![]()
@akoutmos
LostKobrakai
Did you try it?
It’s documented here: ecto_sql/lib/ecto/adapters/sql.ex at 2ec71d74655cc076b6c965740a357dfe1505883a · elixir-ecto/ecto_sql · GitHub and here’s the macro, which adds it to the repo: ecto_sql/lib/ecto/adapters/sql.ex at 2ec71d74655cc076b6c965740a357dfe1505883a · elixir-ecto/ecto_sql · GitHub
It’s not part of the Ecto.Repo behaviour though, which is why it’s not documented in that module. It’s only available if you’re using a SQL based adapter.
LostKobrakai
I don’t know what exactly happens behind the scenes, but I doubt the db does actually interpolate values:
Repo.explain(:all, query)









