-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Mix.install([{:sql, "~> 0.4.0"}])
# Mix.install([{:sql, github: "elixir-dbvisor/sql", branch: "main"}])
defmodule Bug do
import SQL
def run do
name = "alice"
min_age = 18
{sql, params} =
~SQL[WHERE name = {{name}} SELECT id, {{min_age}} AS threshold FROM users]
|> SQL.to_sql()
IO.puts("""
SQL: #{sql}
Params: #{inspect(params)}
First ? (SELECT threshold) bound to: #{inspect(Enum.at(params, 0))} — expected: #{inspect(min_age)}
Second ? (WHERE name) bound to: #{inspect(Enum.at(params, 1))} — expected: #{inspect(name)}
""")
end
end
Bug.run()SQL: select id, ? as threshold from users where name = ?
Params: ["alice", 18]
First ? (SELECT threshold) bound to: "alice" — expected: 18
Second ? (WHERE name) bound to: 18 — expected: "alice"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working