Check for assertions in sql files (Linting/Quality)


I'm trying to put a check for assertions in my sqlx files. When I say, a check for assertions I want some "linting" measure that checks whether I have enough assertions in my sqlx files or not. I couldn't find any out-of-the-box/in-built tolls for this. Therefore, what I did was the following:

  1. I calculated the number of sql statement in a file – which are statements terminated by a semi colon minus the comments
  2. I calculated the number of times we have word “assertion”/assert
  3. I took the ratio
  4. I do this for all files.
  5. Wen I run my ci/cd I get some idea of the quality of checks in the sqlx
    IS this a justified approach? IS there any inbuilt rule that does it better? Any suggestions?

I'm unclear by your reference to "sqlx files". is a Microsoft SQL Server site, most SQL Server scripts use a .sql extension and don't contain assertions, there's not built-in assertion for T-SQL.

Are you referring to assertions used by the tSQLt framework: