For everyone complaining about orm-something - take a look at elixir's Ecto. It basically allows writing sql via native code. Good for composability, type casting, stuff like that.
Account
|> where(active: true)
|> join(:left, [a], p in Post, on: p.account_id == a.id)
|> where([a, p], a.foo == "bar" or p.bar == "foo")
|> group_by([a, p], a.id)
|> select(...)
|> limit(10)
...
|> Repo.all()
Plus there are changesets for data validations (can e.g. catch and return uniquness errors via unique index)P.S. For update/insert queries it doesn't make sense to write UPDATE statement by hand
UPDATE accounts SET ... 50 fields ... WHERE id = 1
P.P.S. changeset example: def changeset(record, attrs) do
record
|> cast(attrs, [:number, :note])
|> validate_required([:number])
|> validate_format(:number, number_format())
|> unique_constraint(:number, name: "foo_bar_index")
end
will return nice error if number is missing (_before_ running sql query) or already taken (_after_ running a query, on DB error)