SQL query string generation code and tests.