-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Elixir version
Elixir 1.15.6 (compiled with Erlang/OTP 26)
Database and Version
N/A
Ecto Versions
3.11.1
Database Adapter and Versions (postgrex, myxql, etc)
N/A
Current behavior
As far as I see, it's not possible to use "aliases" within splice/1
iex> Mix.install(ecto: "3.11.1")
iex> import Ecto.Query
iex> from seq in "pg_class",
...> where: seq.relkind == "S",
...> select: %{
...> seq_name: fragment("concat_ws(?, ?)", ".", splice(^["public", seq.relname]))
...> }
error: undefined variable "seq"
iex:6
** (CompileError) cannot compile code (errors have been logged)outputs
error: undefined variable "seq"
iex:6
** (CompileError) cannot compile code (errors have been logged)
Obviously, this is a minimal reproduction. My goal would be to define a macro for concat_ws
defmacro concat_ws(separator, expressions) do
quote bind_quoted: [separator: separator, expressions: expressions] do
fragment("concat_ws(?, ?)", separator, splice(^expressions))
end
endThen use it like this
select: %{
seq_name: concat_ws(".", ["public", seq.relname])
}Expected behavior
I expect aliases to be recognized within splice/1