Packages

kysely

0.29.9 · 12 Nov 2026MIT32M / weekRepositoryHomepagenpmAtom feed

Your version

0.28.0

13 Apr 2025Where it was published

0.29.9 is the newest release of 0.28.x.

In short

10 breaking28 new6 fixed2 changed5 internal

  • Breaking

    InferResult now outputs InsertResult, UpdateResult, DeleteResult, MergeResult, instead of InsertResult, UpdateResult, DeleteResult, MergeResult. To get the singular form, use type 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 preventAwait is now removed on all builders, you must avoid awaiting builders without calling execute-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.numUpdatedOrDeletedRows has been removed (after spending ~2 years in deprecation). We still log a warning. Outdated dialects that don't use QueryResult.numAffectedRows should be updated OR forked.

  • Breaking

    DefaultQueryExecutor.compileQuery now requires passing a queryId argument. Use the newly exported createQueryId() as that argument value from now on.

  • Breaking

    UpdateValuesNode type has been removed.

  • Breaking

    MssqlDialectConfig.tedious.resetConnectionOnRelease has been deprecated, and had it's default flipped to false. Use MssqlDialectConfig.resetConnectionsOnRelease instead.

Security

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

  • InferResult should output plural.

  • Speedup types with huge databases. Fixes #867

  • Implement missing expression features

  • Remove preventAwait

  • Add ControlledTransaction. by @igalklebanov in #962 & #1193

  • await 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 queryId to CompiledQuery and 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

  • Allow read-only transactions in Postgres and MySQL by B4nan in #1342 & #1350

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 returning support in MERGE queries.

  • 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

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

    InferResult now outputs InsertResult, UpdateResult, DeleteResult, MergeResult, instead of InsertResult, UpdateResult, DeleteResult, MergeResult. To get the singular form, use type 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 preventAwait is now removed on all builders, you must avoid awaiting builders without calling execute-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.numUpdatedOrDeletedRows has been removed (after spending ~2 years in deprecation). We still log a warning. Outdated dialects that don't use QueryResult.numAffectedRows should be updated OR forked.

  • Breaking

    DefaultQueryExecutor.compileQuery now requires passing a queryId argument. Use the newly exported createQueryId() as that argument value from now on.

  • Breaking

    UpdateValuesNode type has been removed.

  • Breaking

    MssqlDialectConfig.tedious.resetConnectionOnRelease has been deprecated, and had it's default flipped to false. Use MssqlDialectConfig.resetConnectionsOnRelease instead.

  • Breaking

    MssqlDialectConfig.tarn.options.validateConnections has been deprecated. Use MssqlDialectConfig.validateConnections instead.

  • 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.