I'm building an application that generates a lot of sql queries. Some of them are complex (to me) and writing good tests is tricky.
As a sanity test it would be nice to run the generated SQL queries through a linter. So, the tests wouldn't actually run/execute the queries on the database, but it would parse the query and make sure it looks valid.
I realize this isn't a great test, but I figure it would be fast, and my PHP linter has helped me catch a lot of issues, so if I could build this into unit tests it seems like a fast way to catch some low hanging fruit.
I'm working in PHP and MySql (on linux) so I'd prefer a solution for that environment but I'll take what I can get. Maybe it will point me in the right direction.
Several possibilities (I confess - the only one I'm personally familiar with is SQL Fiddle):
SQL Fiddle: http://sqlfiddle.com/
MySql Test Framework:
http://dev.mysql.com/doc/mysqltest/2.0/
http://dev.mysql.com/doc/mysqltest/2.0/en/unit-tests-google-test.html
https://github.com/hepabolu/mytap
Since you're using PHP, you should probably also look at PHPUnit:
'Hope that helps ... at least a little
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With