Maybe we should treat SQL like JavaScript, and use it as a compiler target instead of coding in it directly. /s
I wish more languages compiling to SQL were more common.
(Not ORMs though they just miss the point entirely..)
In my experience when you need to escape to raw SQL there is still some kind of query builder employed, which too becomes another "compile to SQL" source.