Repository navigation
Releases: ismailkarsli/TypeSQL
Release list
@typesql/prisma@0.1.5
Patch Changes
- Updated dependencies:
- @typesql/core@0.4.0
@typesql/prisma@0.1.4
Patch Changes
- Updated dependencies:
- @typesql/core@0.3.0
@typesql/prisma@0.1.3
Patch Changes
- Updated dependencies:
- @typesql/core@0.2.0
@typesql/postgres@0.1.3
Patch Changes
- Updated dependencies:
- @typesql/core@0.2.0
npm: https://www.npmjs.com/package/@typesql/postgres/v/0.1.3
@typesql/pg@0.1.3
Patch Changes
- Updated dependencies:
- @typesql/core@0.2.0
@typesql/kysely@0.1.3
Patch Changes
- Updated dependencies:
- @typesql/core@0.2.0
@typesql/drizzle@0.1.3
Patch Changes
- Updated dependencies:
- @typesql/core@0.2.0
@typesql/core@0.4.0
Minor Changes
- Editor completions inside
sql()strings:@typesql/core/editorsuggests tables, views, schemas and columns (with their types) at the cursor, for the new TypeSQL VS Code extension on top of TypeScript 7.1. See the "Editor completions" guide.
@typesql/core@0.3.0
Minor Changes
-
Parse cursor statements (
DECLARE ... CURSOR FOR querychecks its query and types its parameters;FETCH,MOVE,CLOSE),END,ABORTandREASSIGN OWNED, and more DDL as PostgreSQL 18 does:CREATE RECURSIVE VIEW,CREATE SCHEMAwith embedded elements (applied byApplyDdl), table-level andALTER TABLE ... ADDNOT NULL col,NO INHERIT,[NOT] ENFORCED,WITHOUT OVERLAPSkeys,CREATE TABLE ... OF type,AS EXECUTE, any type modifier list and anyPARTITION BYstrategy. -
Any operator Postgres can lex is accepted: user-defined and geometric operators such as
*=,~<~,|>>or@-@, prefix operators like@@ boxandOPERATOR(schema.op) x; built-in geometric tests type asboolean, unknown operators asunknown. -
Parse and type more PostgreSQL expression syntax: typed literals with keyword type names (
timestamp with time zone '…',char(20) '…',interval(2) '…'), named (f(a => 1),f(a := 1)) andVARIADICarguments,x LIKE ANY (…)andop ANY/ALLwith every operator,(a, b) OVERLAPS (c, d),AT LOCAL,IS [NFC|…] NORMALIZED,COLLATION FOR (…),SUBSTRING(… SIMILAR … ESCAPE …),e[i].field, severalWITHIN GROUPsort keys, andCURRENT_DATE,CAST(…)orCOLLATION FOR (…)in FROM. -
Queries can use
ROWS FROM (f(…), g(…)) [WITH ORDINALITY],TABLESAMPLE method (…) [REPEATABLE (…)],SEARCH/CYCLEon recursive CTEs (the columns they add are typed), joins nested Postgres-style (a JOIN b LEFT JOIN c ON … ON …,((SELECT …) s JOIN t ON …) j) andWITHIN GROUP (ORDER BY a, b). -
SQL/XML is parsed and typed:
XMLELEMENT(NAME n, XMLATTRIBUTES(…), …),XMLFOREST,XMLCONCAT,XMLPI,XMLROOT,XMLPARSE,XMLSERIALIZE(… AS type),XMLEXISTS(… PASSING …),IS [NOT] DOCUMENTandXMLTABLE(… COLUMNS …)inFROM, with Postgres's column names, types and nullability. -
The SQL/JSON syntax of PostgreSQL 16+ parses and is typed:
JSON_OBJECT,JSON_ARRAY(values or a query),JSON_OBJECTAGG/JSON_ARRAYAGG,JSON,JSON_SCALAR,JSON_SERIALIZE,JSON_EXISTS/JSON_VALUE/JSON_QUERYwith all their clauses,IS [NOT] JSON, andJSON_TABLEin FROM with typed columns. -
Queries can use
MERGE(WHEN [NOT] MATCHED [BY SOURCE | BY TARGET],RETURNINGwithmerge_action(), insideWITH),RETURNING old.*/new.*andRETURNING WITH (OLD AS o, NEW AS n), array,jsonband field assignment targets (SET a[1] = $1,INSERT INTO t (c.f)),WHERE CURRENT OFandSELECT … INTO new_table, all checked and typed like PostgreSQL 18.
Patch Changes
-
The package description and README say the parser is tested against PostgreSQL 18's regression suite and link to how.
-
Strings and numbers lex like Postgres:
E'\\'and other escaped backslashes before the closing quote, string literals continued on the next line,U&'…'/U&"…"withUESCAPE, invalid Unicode escapes and trailing junk such as123abcare errors, and numbers of any length no longer fail with TS2589. -
Recognising
SELECT … INTOcosts ordinary SELECT statements less type-checking work. -
A JOIN's
ONcondition can only reference the two sides of its join,SELECT DISTINCTneeds a target list, and a function inFROMcannot haveOVER/FILTER/WITHIN GROUP, as in Postgres. -
The pattern forms of
SUBSTRING(FROM 'regex',SIMILAR … ESCAPE …) are nullable,FETCH … WITH TIESmay be followed byOFFSET, andCREATE VIEW … USINGis a syntax error, as in Postgres.
@typesql/core@0.2.0
Minor Changes
-
An optional type cache: with TypeScript 7.1, list
@typesql/coreundercontentMappersin tsconfig and add a.typesqlcachefile, and a background job keeps it filled with query, call and DDL results that the checker uses instead of computing them again, only while everything they were computed from is unchanged (500 queries: 2.6 s of check time without, 0.13 s with). See the "Type cache" guide. -
Requires TypeScript 7.1 or later (7.1.0-beta works), declared as a peer dependency.
Patch Changes
-
Type-checking a query costs a little less: the scans for
$n,:nameand quoted text at the call site do less work. -
Building a query with
:nameparameters or{slot}fragments takes about half as long: the text rewrites are remembered per statement.