Sql tips for your everyday world
Ecto → Raw SQL Have you ever wanted to chuck an ecto query into your sql tool of choice? Here’s a handy snippet that will output your ecto query into a state that you can directly copy/paste to sql.
:all |> Ecto.Adapters.SQL.to_sql(Repo, <insert ecto query here>) |> Tuple.to_list() |> Enum.at(0) |> String.replace("\"", "") |> Kernel.<>(";") |> IO.inspect(label: "QUERY HERE") Example output:
QUERY HERE: "SELECT l2.id, d4.geo_point, d4.zip_code FROM ….. WHERE (d4.
read more