Home / Learn Secure SQL / Elixir: Ecto Query Parameters
Elixir: Ecto Query Parameters
Pin-matched variables as safely bound values.
The gistPin-matched variables as safely bound values.
The idea, explained simply
The basic idea
Elixir's Ecto library lets you write queries with Elixir syntax, where any variable referenced (often with the ^ pin operator in raw fragments) becomes a bound parameter, never inlined text.
Why this comes up
Ecto's design makes the safe pattern the natural, idiomatic way to write a query, rather than an extra step a developer must remember.
The mechanics
Use Ecto's query syntax directly, and when writing a raw fragment, pin (^) the variable so Ecto binds it as a parameter.
Where it is used
- Web application code review
- Backend development
- Database administration
import Ecto.Query
query = from(u in User, where: u.email == ^email)
user = Repo.one(query)Quick check
1. In Ecto, the ^ (pin) operator in a query mainly signals...
Marks a bound value.