TIL Using raw SQL inside of Ecto.Query

TIL: Use the Ecto.Query.fragment function if you need to add some raw sql in your query.

Example:

q = from p in "posts",
where: fragment("lower(?)", p.title) == "foo bar", select: [:id, :title]

Learn more about it here https://hexdocs.pm/ecto/Ecto.Query.html#module-fragments

c