Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

Ecto query to SQL

Ecto exposes a to_sql function on your ecto Repo. Check this out:

query = from u in User,
          where: == "Foo Bar",
          select: [:id, :name]

Repo.to_sql(:all, query)

# {
#   "SELECT t0.\"id\", t0.\"name\" FROM \"users\" AS t0 WHERE (t0.\"name\" = 'Foo Bar')",
#   []
# }
Looking for help? At Hashrocket, we 💜 Elixir! From our many Elixir client projects, to sponsoring the Chicago Elixir Meetup, to the source code for this application, we are invested in this community. Contact us today to talk about your Elixir project.