I'm still waiting for a compile-to-sql language in the vein of coffeescript or typescript. It seems like there is so much that could be improved with some very simple syntax sugar: variables, expression fragments and even real basics like trailing commas.
For me that's ecto (an elixir dsl for performing queries). The single defining improvement is I can define reusable building blocks. (This is also why I like react-style frameworks over raw js).
entry_of(record)
|> select_basic_info()
def entry_of(record) do
Entry
|> where(record_id: record.id)
end
def select_basic_info(query) do
query
|> select([entry], BasicEntey.new(entry.foo, entry.bar))
end
Tagged template combinators work surprisingly well [0] for injection sanitation/intuitive fragment generation while giving access to full set features of underlying database.