Skip to content

SQLTy vs sqlvet

Both statically check raw SQL in Go code against a schema file, with no database. sqlvet checks syntax, table and column names and INSERT column counts in database/sql, sqlx, gorm and gorp calls. SQLTy checks the same, plus row and parameter types, nullability and call arguments, as a go vet analyzer.

Quick comparison

sqlvet 1.2 SQLTy for Go (preview)
Runs as Its own CLI go vet analyzer, golangci-lint plugin
Calls checked database/sql, sqlx, gorm, gorp pgx v5
Names, syntax Yes Yes, with did-you-mean
Row and argument types No (a TODO in its README) Yes
Schema One DDL file DDL files, directories, migrations
Dialects PostgreSQL syntax PostgreSQL
Rules About 5 Over 70

Where SQLTy is stronger

  • Types, nullability and argument checks, in go vet with positions inside the SQL string.
  • Migrations as the schema.

Where sqlvet is stronger

  • It checks database/sql, sqlx, gorm and gorp calls.

Which should you choose?

On pgx, choose SQLTy. On database/sql, sqlx or gorm, sqlvet works today.

What SQLTy is missing

  • database/sql, sqlx and gorm calls.

Common questions

Can sqlvet and SQLTy run together?

Yes. sqlvet is its own CLI and SQLTy runs under go vet, so a project can run both.

Sources