Ecto’s query syntax does not cater to all types of database queries.
fragment is useful to inject custom SQL for composing queries.
Lets take a very simple example to
lowercase a target column while comparing a string in
where clause in our SQL query. We can use
fragmentto inject custom SQL into our query.
email = "email@example.com" query = from u in User, where: fragment("lower(?)", u.email) == ^email, select: u.email Repo.all query