kysely
0.29.9 · 12 Nov 2026MIT32M / weekRepositoryHomepagenpmAtom feed
0.29.9 is the newest release of 0.28.x.
In short
10 breaking28 new6 fixed2 changed5 internal
- Breaking
InferResultnow outputsInsertResult,UpdateResult,DeleteResult,MergeResult, instead ofInsertResult,UpdateResult,DeleteResult,MergeResult. To get the singular form, usetype Result = InferResult<T>[number]. - Breaking
Some generic/wide usages of
QueryCreator's methods should no longer pass type checks. We never supported these officially. - Breaking
As
preventAwaitis now removed on all builders, you must avoid awaiting builders without callingexecute-like methods on your own. - Breaking
TypeScript versions 4.5 and older are no longer supported. You will get an immediate compilation error telling you to upgrade.
- Breaking
QueryResult.numUpdatedOrDeletedRowshas been removed (after spending ~2 years in deprecation). We still log a warning. Outdated dialects that don't useQueryResult.numAffectedRowsshould be updated OR forked. - Breaking
DefaultQueryExecutor.compileQuerynow requires passing aqueryIdargument. Use the newly exportedcreateQueryId()as that argument value from now on. - Breaking
UpdateValuesNodetype has been removed. - Breaking
MssqlDialectConfig.tedious.resetConnectionOnReleasehas been deprecated, and had it's default flipped tofalse. UseMssqlDialectConfig.resetConnectionsOnReleaseinstead.
Security
3 advisories affect 0.28.0; 0.28.17 fixes them
- HighKysely: JSON-path traversal injection via unsanitized path-leg metacharacters in `JSONPathBuilder.key()` / `.at()`GHSA-pv5w-4p9q-p3v2 · 11 May 2026Fixed in 0.28.17
- HighKysely has a MySQL SQL Injection via Insufficient Backslash Escaping in `sql.lit(string)` usage or similar methods that append string literal values into the compiled SQL stringsGHSA-8cpq-38p9-67gx · 20 Mar 2026Fixed in 0.28.14
- HighSQL Injection via unsanitized JSON path keys when ignoring/silencing compilation errors or using `Kysely<any>`.GHSA-wmrf-hv6w-mr66 · 18 Mar 2026Fixed in 0.28.12
Release note
Hey 👋
Transactions are getting a lot of love in this one!
As part an effort to replace Knex with Kysely, B4nan, the author of mikro-orm drove the new setAccessMode('read only'|'read write') method when starting transactions.
You can now commit/rollback transactions manually and there's even savepoint support:
const trx = await db.startTransaction().execute()
try {
// do stuff with `trx`, including work with savepoints via the new `savepoint(name)`, `rollbackToSavepoint(name)` and `releaseSavepoint(name)` methods!
await trx.commit().execute()
} catch (error) {
await trx.rollback().execute()
throw error
}We also added using keyword support, so now you can write:
await using db = new Kysely({...})and db.destroy() will be called automatically once the current scope is exited.
If you plan on trying this out (it is optional, you can still const db = new Kysely({...}) and await db.destroy() manually), the using keyword requires typescript >= 5.2 and the following tsconfig.json options:
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ESNext", ...],
...
}
...
}We also added a plugin to handle in () and not in (). It comes with 2 handling strategies, one similar to how Knex.js, PrismaORM, Laravel and SQLAlchemy do it, and one similar to how TypeORM and Sequelize do it. It also supports custom strategies, e.g. throwing an error to avoid making a call to the database and wasting resources. Here's an example with one of the strategies we ship:
import {
// ...
HandleEmptyInListsPlugin,
// ...
replaceWithNoncontingentExpression,
// ...
} from 'kysely'
const db = new Kysely<Database>({
// ...
plugins: [
new HandleEmptyInListsPlugin({
strategy: replaceWithNoncontingentExpression
})
],
})
// ...
.where('id', 'in', [])
.where('first_name', 'not in', []) // => `where 1 = 0 and 1 = 1`Features
InferResultshould output plural.Speedup types with huge databases. Fixes #867
Implement missing expression features
Remove preventAwait
Add
ControlledTransaction. by @igalklebanov in #962 & #1193await using kysely = new Kysely()support.Add HandleEmtpyInListsPlugin.
Add Date as a valid return type for max and min by @samclearman & @igalklebanov
Add support for cross join and cross join lateral
Dry up joins.
Revisiting orderBy - deprecations, new order by item builder (nullFirst(), nullsLast(), collate()).
Add
queryIdtoCompiledQueryand all transformer methods.Add disableTransactions option to Migrator
Redundant export UpdateValuesNode removed
Fix ctrl transaction mutation issues
Escape single quotes in string literals.
PostgreSQL 🐘 / MySQL
PostgreSQL 🐘 / MS SQL Server
Add within group clause support for aggregate function builder
PostgreSQL 🐘 / SQLite
Add support for deferrable constraints.
PostgreSQL
Support refresh materialized view
Add
returningsupport inMERGEqueries.Support json_agg(column_ref)
Expands limit in select accepting null value
Make create type as enum values argument readonly.
Add support for constraint renaming.
MySQL
Support update table1, table2, ... query support. Closes #192
MS SQL Server
Add outer and cross apply (mssql)
SQLite
SQLite's OR CONFLICT clause for inserts by @vincentiusvin & @igalklebanov
Bugfixes
No logging in streams.
ImmediateValueTransformer not handling PrimitiveValueListNodes.
Allow empty array for sql.join
PostgreSQL
Postgres auto increment introspection is wrong after column renames.
CICD & Tooling
Fix package-lock.
Add TypeScript benchmarks.
Improve join tests dialect coverage.
Minor ci tweaks.
Breaking Changes
- Breaking
InferResultnow outputsInsertResult,UpdateResult,DeleteResult,MergeResult, instead ofInsertResult,UpdateResult,DeleteResult,MergeResult. To get the singular form, usetype Result = InferResult<T>[number]. - Breaking
Some generic/wide usages of
QueryCreator's methods should no longer pass type checks. We never supported these officially. - Breaking
As
preventAwaitis now removed on all builders, you must avoid awaiting builders without callingexecute-like methods on your own. - Breaking
TypeScript versions 4.5 and older are no longer supported. You will get an immediate compilation error telling you to upgrade.
- Breaking
QueryResult.numUpdatedOrDeletedRowshas been removed (after spending ~2 years in deprecation). We still log a warning. Outdated dialects that don't useQueryResult.numAffectedRowsshould be updated OR forked. - Breaking
DefaultQueryExecutor.compileQuerynow requires passing aqueryIdargument. Use the newly exportedcreateQueryId()as that argument value from now on. - Breaking
UpdateValuesNodetype has been removed. - Breaking
MssqlDialectConfig.tedious.resetConnectionOnReleasehas been deprecated, and had it's default flipped tofalse. UseMssqlDialectConfig.resetConnectionsOnReleaseinstead. - Breaking
MssqlDialectConfig.tarn.options.validateConnectionshas been deprecated. UseMssqlDialectConfig.validateConnectionsinstead. - Breaking
String literals are now
'injection protected, hopefully. Please report any issues.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.