ts-sql-query is a type-safe SQL query builder for TypeScript, inspired by Java's QueryDSL and JOOQ, supporting MariaDB, MySQL, Oracle, PostgreSQL, SQLite, and SQL Server. Current stable version is 1.67.0, with regular releases following minor updates. It emphasizes compile-time type checking for SQL queries, dynamic query construction, and avoids ORM patterns, making it suitable for projects requiring full SQL control without string concatenation. Unlike Knex or TypeORM, it provides first-class TypeScript support with inferred result types and no runtime schema generation.
npm install ts-sql-queryNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Defines a customer table, creates a connection to PostgreSQL, and runs a type-safe select query with one result.
Update imports to use the new subpath, e.g., 'ts-sql-query/connections/PostgreSqlConnection'.
Switch to importing from 'ts-sql-query/connections/<Database>Connection'.
Ensure your table class extends `Table` and correctly passes the table name to `super()`.
Use `executeSelectNoneOrOne()` if you expect no row, or catch the error.
Always import from specific subpaths like 'ts-sql-query/Table', 'ts-sql-query/Connection', etc.
Change import to a specific subpath, e.g., import { Table } from 'ts-sql-query/Table'.Ensure the class extends `Table` and calls `super('table_name')`.Check the query runner implementation; ensure it returns an object with `rows` and `affectedRows`.
Check the query runner interface; it should be `(query: string, params: any[]) => Promise<{ rows: any[], affectedRows: number }>`.No dependency data recorded yet.