by ddevault · 5y ago · 0 comments
One thing which is occasionally useful is a query building tool. For Go we use squirrel for this purpose. If you need unrelated parts of the code to work together to produce a single SQL query, it can help to have such a tool. This is a lot less than a full blown ORM, though, it's more like passing around a SQL AST in memory.
I’ve even written reports with it.
* while still relying on safe query parameterization, of course.
I validated it by checking out what it would generate via its internal SQL compiler.
So for me, it was more like, am I competent enough to write less code and fewer mistakes, due to functions, autocomplete, etc. versus writing the full SQL.
It's a time saving for me, and the queries are expected. I also echo the SQL query to make sure that that's the exact query I want.
Lastly, I then groused at the engineer who decided that the query pulled in so much crap from so many tables in 1 query.