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.
First Post!
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)
Last Post!
waseigo
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex











