4 ms·
Being fair, there really aren't tools built to test SQL queries like there are to test other code.
by roflyear 3y ago
Being fair, there really aren't tools built to test SQL queries like there are to test other code.
- freetime2 3y agoWe use integration tests to test our SQL queries. Basically fire up our persistence layer and a database instance together, call some create/update methods, and assert that the expected results are returned. Writing tests is pretty straightforward - the tests proved incredibly valuable recently when we migrated to a different RDBMS provider. But yeah I guess we don't really have a good way to write automated tests for migrations that run outside of our application code.
- ttfkam 3y agoDDL is like code. DML is not. Tools like Sqitch are quite adept at testing DDL. DML is declarative. Like HTML. SQL is a DSL for set theory. Do you test your HTML like the rest of your code too? But to be clear, Sqitch and pg_tap (off the top of my head) are both effective testing tools for Postgres databases. MS SQL and Oracle both have extensive testing frameworks available.
- roflyear 3y agoSure. HTML doesn't impact as much as the app as SQL does. Missing records in a SQL query can have a huge impact on many systems. A missing table row (HTML) doesn't usually impact that much.