Repository navigation
sqlty 0.10.0 checks typed raw SQL in Go under go vet, checks and types rustmy and asyncpg calls, and adds rules for NULL writes, UPDATE and DELETE without WHERE, argument counts, duplicate output columns and repeated parameters. The language server gains completion of functions, keywords and enum values, signature help, go to definition and semantic tokens.
pip install -U sqlty # or: uv add sqlty@latest
brew install jirikuncar/sqlty/sqlty # the native executable
brew install jirikuncar/sqlty/sqlty-vet # the go vet tool
npx @sqlty/cli check # the native executable, from npmUpgrading
- New errors can fail a check that passed on 0.9.0 (all
errorby default):null-write: a literalNULLwritten to aNOT NULLcolumn, inINSERT,UPDATE,ON CONFLICT DO UPDATEandMERGE. PostgreSQL only; a table with aBEFORErow trigger is skipped (#1534)argument-count-mismatch: a built-in called with an argument count that fits none of its overloads, and*passed to a function other thancount. Reported at the function name. Functions the schema defines, named arguments and table functions are not checked (#1434, #1558, #1671)duplicate-column: a query read into a row mapped by name (TypedDict, dataclass, Pydantic,Protocol,dict) with two columns of one name. Alias one:p.id AS p_id(#1529)set-column-count: aUNION,INTERSECTorEXCEPTbranch with another column count than the first (#1415)position-out-of-range: anORDER BYorGROUP BYposition that names no select item (#1418)column-alias-count: an alias list longer than the relation it renames, or shorter on MySQL and SQLite CTEs (#1424)rejected-queryfor a parameter used twice with types of different categories, which PostgreSQL rejects:id = %(x)s OR name = %(x)s. SQLite reports nothing (#1557)unknown-tablefor a qualifier that names noFROMitem:SELECT users.id FROM orgsandSELECT users.id FROM users AS u(#1398)param-type-mismatchfor astrliteral argument that PostgreSQL's input function for the parameter's type rejects ("abc"for an integer,"2026-02-30"for a date) and for an enum orCHECK (col IN (...))parameter given a value the column never holds (#1403)params-type-mismatchandparam-type-mismatchnow also judge parameters of aCHAR(n)column whoseCHECKvalues are shorter thann; trailing spaces of both sides are ignored, as the server does (#1707, #1710)ungrouped-columnnow judgesSELECT *overJOIN ... USINGandNATURAL JOINwithGROUP BY. AGROUP BYposition with*is no longer judged (#1701)position-out-of-rangemakesungrouped-columnsilent for that position (#1418)json-shape-mismatchnow checks the field types of a Pydantic model, not only its keys, with the conversions Pydantic performs: a lax field takes a JSON string for any scalar and a JSON integer forbool, a strict field (strictconfig,Field(strict=True),Strict*types) keeps theTypedDictrules. A number intostror an array into a scalar is reported (#1726)
- New warnings where 0.9.0 was silent:
missing-where:UPDATEorDELETEwithoutWHERE, in queries and.sqlquery files.WHERE truemeans it. Migrations keepunbatched-backfill(#1517)nullable-write: a value that can be NULL, such as a nullable column or aLEFT JOINcolumn, written to aNOT NULLcolumn. PostgreSQL only (#1534)unused-cte: a CTE nothing reads. Editors fade it (#1422)unknown-functionfor a table function inFROMthat is neither built in nor defined by the schema, with acheck --fixsuggestion (#1436)fanout-aggregateandunproven-joinnow see the key of a derived table with its ownWITH, so joins to it are judged where they were skipped (#1691)
rewritewrites different parameter types than on 0.9.0, so your nextrewritechanges them:- A
CHAR(n)column whoseCHECKvalues all havencharacters isLiteral[...]instead ofstr:CHAR(1) CHECK (c IN ('Y', 'N'))isLiteral['Y', 'N']. A shorter value keepsstr.literal-writeandunmatched-literalignore trailing spaces on PostgreSQL (#1546) - Types that changed to follow the server:
- PostgreSQL: a subscript of
text[][]istext, as the server types it (#1399) - MySQL: an integer literal above
BIGINT UNSIGNEDisDecimal;JSON_TABLEcolumns underNESTED PATHare nullable (#1634);GROUP_CONCATand string functions ofBITor binary values returnbytes;BIGINT UNSIGNEDwith an integer literal isDECIMAL;TIMESTAMPwith a string literal is a string;CAST(bytes AS CHAR)can be NULL (#1581, #1585) driver = "asyncpg"typesjson/jsonbasstr,bit/varbitasasyncpg.BitString, geometric types asasyncpg.Pointand the like, ranges asasyncpg.Range[T]; a[tool.sqlty.types]entry for a SQL type now applies to every result value of that type, not only columns (#1416)
- PostgreSQL: a subscript of
- A qualified column alias list on a table, view or CTE renames its columns, as on PostgreSQL and DuckDB:
SELECT id FROM users AS u(a)is nowunknown-column(#1495) sqlty checknow reads\N{name}escapes in query strings as Python does (#1401)
Go
Typed raw SQL for Go, checked in go vet and golangci-lint with no generated code and no database (preview) (#1498).
sqlty.SQL[R, P],NoParamsandNoRowsin the modulegithub.com/jirikuncar/sqlty/go;pgxqruns them through pgx v5 (All,One,Exec,Each,QueueAll,QueueOne,QueueExec)sqlty-vetapplies the SQL rules ofsqlty checkwith your[rules]severities, checks row struct fields aspgx.RowToStructByNamematches them, nullability, the Go types pgx scans, and the arguments ofpgxqcalls and of pgx'sQuery,QueryRow,ExecandBatch.Queuegivenstring(q). 74 µs per query in the analyzer, 100 ms for a package of 1,000 queries- Linux (glibc 2.35 or newer, not Alpine) and macOS; no Windows build yet
- GitHub Action
jirikuncar/sqlty/go@vX.Y.Zrunsgo vetand annotates each finding - Diagnostics carry
go/analysissuggested fixes:nullable-mismatchturns a field into a pointer,redundant-optionalremoves it, andunknown-columnandunknown-tablereplace the name in the query literal. A field changes only when nothing else can read it (#1712) brew install jirikuncar/sqlty/sqlty-vetinstalls the tool alone; thesqltyformula ships onlysqlty(#1666)- A Go example in the playground (#1665); comparison pages for pggen, Bob, go-jet, scany/sqlx and sqlvet (#1553)
ESLint/TypeScript
sqlty/check-sqlaccepts a named row type:sql<User[]>is no longer reported as a mismatch, andeslint --fixno longer inlines the literal, whenUserhas exactly the row's shape (#1657)duplicate-columnis reported for every query. AfieldTransformthat maps two columns to one key is reported and gets no row type (#1529)@sqlty/wasmanswers one bare SQL query withop: "query": columns, parameters and diagnostics (#1390)
Drivers
- rustmy:
sqlty checkchecks the parameters ofexecuteandexecutemanyon connections, cursors and pools fromrustmy.connect,rustmy.aio.connect,rustmy.Poolandaio.create_pool, withparam-count-mismatch,param-type-mismatchandextra-param(#1484).sqlty.drivers.rustmy(extrasqlty[rustmy]) has typedexecute,execute_async,scalarandscalar_async, blocking and async (#1485); example projectexamples/09_rustmy(#1486) - asyncpg: values typed as asyncpg loads them (see Upgrading) (#1416);
.acquire()on an asyncpg pool is followed (#1484) - psycopg: calls on a subscripted annotation,
conn: Connection[tuple[object, ...]],AsyncConnection[...],Cursor[...]and aliases of them, are checked (#1506)
Checks
- Repeated parameters: a named parameter or
$1used more than once takes the type of its first typed use in every dialect (#1557) - SQLite function signatures from the SQLite documentation, so SQLite gets hover, signature help and
argument-count-mismatch(#1558) - Function argument counts follow the databases, including optional parameters and overloads the PostgreSQL docs omit (#1433)
unknown-tablesuggests the closest table, view or CTE, andcheck --fixreplaces the name (#1414);unknown-columnin an unaliased subquery says "in the subquery" (#1400)ambiguous-columnandduplicate-aliaspoint at related locations: theFROMitems that have the column and the earlier use of the alias (#1404)- Extension types and functions, gated by
CREATE EXTENSION: hstore (#1429), pg_trgm, fuzzystrmatch and pgcrypto (#1430), ltree and intarray (#1432), pgvectorvector,halfvecandsparsevecwith distances (#1435) - A SQLite CTE may read a later CTE of its
WITH; PostgreSQL, MySQL and DuckDB still report it (#1500) CHECKconstraints are tracked by name, soALTER TABLE ... DROP CONSTRAINTclears only the values and discriminators of the constraint it names (#1684)LIKEcolumns ofCREATE TABLEstand where theLIKEis written (#1397)- A PostgreSQL operator right after
), as in(id + 1)*2and(id, name)=(1, 'a'), parses (#1619) - Diagnostics of PostgreSQL queries with
?placeholders keep their spans, socheckunderlines the name and--fixcan write (#1686) SELECT '%s'no longer types asLiteral['$0']; a%sinside a string literal or comment is left unbound (#1714)- Python reading: nested format specs in f-strings, aliased
dataclassdecorators,tuple[T, ...]as a variable-length tuple,Literal[-1], andfrom typing import *(#1631) - A schema
**glob stops at a linked directory it is already inside, instead of walking links to 64 levels, and no longer drops files of trees deeper than 64 levels (#1699) -- sqlty: ignore[rulewithout]is a bare ignore at any line ending (#1669)- A helper call spelled with compatibility characters, such as fullwidth
fetch_all(...), is read in NFKC form as Python reads it, so its query is checked (#1721)
Editor and language server
- Completion:
- function names, with the schema's functions first, then the dialect's built-ins (#1431), and table functions in
FROM(#1437) - keywords and clause skeletons that fit the cursor (#1528)
ORDER BYandGROUP BYaliases and positions (#1531)- enum labels and
CHECKvalues inside string literals compared with or written to the column (#1541) - columns of every table before the query has a
FROM(#1439);FROMlists the relations that have the selected columns first (#1440); column names match as a subsequence, souidfindsuser_id(#1442) - schema comments from
COMMENT ONin hover and completion, PostgreSQL and DuckDB (#1421) - the case of a quoted schema qualifier is kept (#1395); names a schema hides no longer use up the completion limit (#1675)
- function names, with the schema's functions first, then the dialect's built-ins (#1431), and table functions in
- Signature help for PostgreSQL (745 overloads), DuckDB, MySQL (402 overloads) and SQLite built-ins, in the server, VS Code and the playground;
signatureHelp.enable = falseturns it off (#1425, #1426, #1427, #1428, #1558) - Go to definition of tables, views and columns to the schema statement that defines them (#1419, #1420), and of CTE and subquery columns,
ORDER BYandGROUP BYaliases and positions to the select item (#1423) - VS Code colors SQL in strings marked
--sqlin TypeScript, JavaScript, Rust and Go files; highlighting only (#1723) - Semantic tokens: names colored by what they resolve to (table, view, schema, alias, column, type, deprecated column) (#1441), function names (#1438), every statement of a query, multi-word types and enum members (#1483), ranges and
.sqlquery files (#1456) - A client that declares
completionList.itemDefaultswitheditRange, such as VS Code, gets the edit range once per list. Server CPU for a completion of a table name with 400 tables and 200 items: 1653 to 1107 µs (#1630)
Playground
- Completion, hover and signature help inside
sqltemplates of the TypeScript example (#1587) - Go quick fixes and "Fix All in File" (#1712)
CLI
sqlty checkreads each walked directory's configuration once, and a file no override matches shares its settings (#1384, #1637)- The Agent Skills ship in the PyPI and npm packages at
.agents/skills/, whereuvx library-skills --claudeandnpx library-skillsfind them (#1457)
Performance
- Parsing schemas and preparing modules run in parallel. On projects of 5,000 and 20,000 tables wall time falls 54 % and 55 % (mimalloc), at 15 to 17 % more CPU; on the synthetic
ciproject at 4x it falls 14 % (#1358) - Costly neighbouring modules are checked on all threads. Wall time on a large project with clustered query modules falls by about a quarter at the same CPU (#1635)
- A bound copy of a query reuses the analysis of the query as written unless an argument decides a column. On a large project, second analyses fall from 1090 to 285 and check CPU from 2661 to 2494 ms (#1638, #1715)
- Schemas of a project's databases load in parallel, about a fifth less schema time with two databases that share a large schema (#1639). A schema that extends another's parses only its added statements: check CPU 2788 to 2696 ms, and a one-file check 233 to 173 ms (#1717)
- The helper index and the file walk are faster: on nested projects of 3,200, 6,400, 12,800 and 25,600 modules, building the helper index went from 25, 82, 301 and 1120 ms to 7, 13, 37 and 81 ms, and the largest checks in 3829 ms instead of 4928 (#1547). The file walk takes half the time on a large tree (#1637)
- The executable and the PyPI command skip freeing the workspace when they exit after
check: about 3 % of wall time on a large project, 891 to 851 ms for the PyPI command (#1636, #1716) - Check and editor work is linear in query size: 2,048 CTEs check in 20 ms instead of 1 s; 4,096
WHENs on distinct columns check in 30 ms instead of 1 s and hover in 86 ms instead of 3.1 s (#1548) FROMcompletion ranking: 5,000 tables 32.2 to 26.4 µs (#1579)
Docs
- Installation lists every channel, with a guide per language (#1591); comparison pages for SQLTy against other tools (#1525, #1553); Go recipe (#1498)
Contributors
Thanks to @Kludex for CHAR(n) parameters and CHECK values, SELECT * over JOIN USING, spans for ? placeholders, DROP CONSTRAINT by name, fan-out keys through WITH, symlink loops in schema globs, the ESLint named row type, the SUBSTRING span, the completion limit, Pydantic field types in JSON columns, NFKC helper names and --sql highlighting in other languages.
Full changelog: v0.9.0...v0.10.0