4 ms·
> A big downside of vanilla database/sql or pgx is that SQL queries are strings What's wrong with strings? The argument in the article is that they cannot be c
by crescentfresh 5y ago
> A big downside of vanilla database/sql or pgx is that SQL queries are strings
What's wrong with strings? The argument in the article is that they cannot be compile-time checked, but I'm confused as to the solution to that problem ("you need to write exhaustive test coverage to verify them"). Is this saying that if they weren't strings you wouldn't need test coverage?
- Scarbutt 5y agoMaybe the key word here is 'exhaustive' What did stand out for me from that section was: This is fine for simple queries, but provides little in the way of confidence that queries actually work. Why not just paste the string first to psql to make sure the query actually works?
- candiddevmike 5y agoThere is a significant number of developers who think requiring a database to run tests is abhorrent, even in the age of containers. Instead, they'd rather write tests and validations in their app code against the query syntax, which ends up being more work and not as comprehensive.
- smoyer 5y agoI like SQL queries as strings but I also like my IDE to syntax check them ... Since there are already so many links to projects in this thread I'll happily introduce fileconst which provides the best of both worlds - https://github.com/PennState/fileconst https://github.com/PennState/fileconst.
- deleted 5y ago[deleted]