4 ms·
SQL is a declarative language. If you ask it for an address, it'll give you an address. Not sure what you're trying to say with that xkcd. SQL is a real langua
by mcdonje 3y ago
SQL is a declarative language. If you ask it for an address, it'll give you an address. Not sure what you're trying to say with that xkcd.
SQL is a real language. It is testable and reusable. It's a DSL, so the syntax isn't something you have to look at most of the time unless you're a DBA. That said, not everyone hates the syntax.
You're probably losing efficiency in your quest for functional paradigm perfection.
- roflyear 3y agoBeing 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.