Packages

kysely

0.29.9 · 12 Nov 2026MIT32M / weekRepositoryHomepagenpmAtom feed

Your version

0.29.0

8 May 2026Where it was published

0.29.9 is the newest release of 0.29.x.

In short

23 breaking2 deprecated24 new1 fixed14 internal

  • Breaking

    Bump minimum TypeScript version to 4.7.

  • Breaking

    Bump minimum TypeScript version to 4.8.

  • Breaking

    Bump minimum TypeScript version to 4.9.

  • Breaking

    Bump minimum TypeScript version to 5.0.

  • Breaking

    Bump minimum TypeScript version to 5.1.

  • Breaking

    Bump minimum TypeScript version to 5.2.

  • Breaking

    Bump minimum TypeScript version to 5.3.

  • Breaking

    Bump minimum TypeScript version to 5.4.

Release note

Hey 👋

This one's a banger! 💥 💥 💥

We got $pickTables, $omitTables compile-time helpers to narrow the world view of downstream queries, cutting down on compilation complexity/time while at it!

const results = await db
  .$pickTables<'person' | 'pet'>() // <----- now `DB` is only { person: {...}, pet: {...} } for following methods.
  .selectFrom('person')
  .innerJoin('pet', 'pet.owner_id', 'person.id')
  .selectAll()
  .execute()

const results = await db
  .$omitTables<'toy'>() // <----- now `DB` doesn't have a "toy" table description for following methods.
  .selectFrom('person')
  .innerJoin('pet', 'pet.owner_id', 'person.id')
  .selectAll()
  .execute()

We got a new ReadonlyKysely<DB> helper type that turns your instance into a compile-time readonly instance!

import { Kysely } from 'kysely'
import type { ReadonlyKysely } from 'kysely/readonly'

export const db = new Kysely<Database>({...}) as never as ReadonlyKysely<Database>

db.selectFrom('person').selectAll() // no problem.
db.selectNoFrom(sql`now()`.as('now')) // no problem.

db.deleteFrom('person') // compilation error + deprecation!
db.insertInto('person').values({...}) // compilation error + deprecation!
db.mergeInto('person')...  // compilation error + deprecation!
db.updateTable('person').set('first_name', 'Timmy') // compilation error + deprecation!
sql`...`.execute(db) // compilation error!
// etc. etc.

We got a brand new PGlite dialect. With it comes a new supportsMultipleConnections adapter flag that uses a new centralized connection mutex when false - should help simplify all SQLite dialects out here!

import { PGlite } from '@electric-sql/pglite'
import { Kysely, PGliteDialect } from 'kysely'

const db = new Kysely<DB>({
  // ...
  dialect: new PGliteDialect({
    pglite: new PGlite(),
  }),
  // ...
})

We got $narrowType supporting nested narrowing and discriminated unions!

db.selectFrom('person_metadata')
  .select(['discriminatedUnionProfile']) 
  // output type inferred as:
  //
  // {
  //   discriminatedUnionProfile: {
  //     auth:
  //       | { type: 'token'; token: string }
  //       | { type: 'session'; session_id: string }
  //     tags: string[]
  //   }
  // }[]
  .$narrowType<{ discriminatedUnionProfile: { auth: { type: 'token' } } }>()
  // output type narrowed to:
  // 
  // {
  //   discriminatedUnionProfile: {
  //     auth: { type: 'token'; token: string }
  //     tags: string[]
  //   }
  // }[]
  .execute()

We got web standards driven query cancellation support. Pass an abort signal to execute* methods and similar. Pick between different inflight query abort strategies - ignore the query, cancel it on the database side or even kill the session on the database side.

  import { Kysely, PostgresDialect } from 'kysely'
  import { Client, ... } from 'pg'

  const db = new Kysely<Database>({
    dialect: new PostgresDialect({
      // ...
      controlClient: Client, // optional, for out-of-pool connections for database side query aborts.
      // ...
    })
  })

  const options = { signal: AbortSignal.timeout(3_000) } // throw abort/timeout errors and ignore query reuslts

  query.execute(options)
  query.stream(options)
  sql`...`.execute(db, options)
  db.executeQuery(compiledQuery, options)
  // etc. etc.

  query.execute({ ...options, inflightQueryAbortStrategy: 'cancel query' }) // also cancel query database side
  query.execute({ ...options, inflightQueryAbortStrategy: 'kill session' }) // also kill session database side

We got SafeNullComparisonPlugin to flip (in)equality operators to is and is not when right hand side argument is null.

import { Kysely, SafeNullComparisonPlugin } from 'kysely'

const db = new Kysely<DB>({
  // ...
  plugins: [new SafeNullComparisonPlugin()],
  // ...
})

db.selectFrom('pet')
  .where('name', '=', null) // outputs: "name" is null
  .where('owner_id', '!=', null) // outputs: "owner_id" is not null
  .selectAll()

We got a new shouldParse(value, path) option in ParseJSONResultsPlugin for granular control of what gets JSON.parse'd and what stays a string using JSON paths.

import { JSONParseResultsPlugin } from 'kysely'

db.selectFrom('person')
  .select((eb) => jsonArrayFrom(
	  eb.selectFrom('pet')
      .where('pet.owner_id', '=', 'person.id')
 	    .selectAll()
  ).as('pets'))
  .withPlugin(new JSONParseResultsPlugin({ 
    shouldParse: (_value, path) => {
      // parse only the pets array
      if (path.endsWith('."pets"')) {
        return true
      }
    
      return false
    } 
  }))

Features

  • utils: Allow explicit undefined in Updateable type (for exactOptionalPropertyTypes support)

  • migrator: Allow disabling transactions in migrate methods.

  • Add thenRef method in eb.case

  • Add whenRef(lhs, op, rhs) in eb.case.

  • Add elseRef in eb.case()

  • Deprecated

    Add $pickTables, $omitTables and $extendTables, deprecate withTables.

  • Add SafeNullComparisonPlugin plugin

  • Add more control through configuration @ ParseJSONResultsPlugin.

  • Deprecated

    Allow expressions in create/add index's column and columns functions, deprecate their expression functions.

  • Add with(name, query).

  • Expose migrations from 'kysely/migration'. deprecate migration exports in root.

  • Breaking

    Bump minimum TypeScript version to 4.7.

  • Breaking

    Bump minimum TypeScript version to 4.8.

  • Breaking

    Bump minimum TypeScript version to 4.9.

  • Breaking

    Bump minimum TypeScript version to 5.0.

  • Breaking

    Bump minimum TypeScript version to 5.1.

  • Breaking

    Bump minimum TypeScript version to 5.2.

  • Breaking

    Bump minimum TypeScript version to 5.3.

  • Breaking

    Bump minimum TypeScript version to 5.4.

  • Support narrowing by deep object keys in NarrowPartial

  • Add ReadonlyKysely<DB> helper.

  • Allow overriding file import function @ FileMigrationProvider.

  • Query cancellation. by @igalklebanov in #1796 & #1797 & #1798 & 33e60df & b739e02 & 4d7064f

  • ParseJSONResultsPlugin: Wrap object keys in quotes.

PostgreSQL 🐘 / MySQL

  • Introspect: Add support for postgres & mysql foreign tables

PostgreSQL 🐘 / MSSQL

  • Migrator: Allow passing transactions to Migrator.

  • Support IF EXISTS in DROP COLUMN

PostgreSQL

  • Support dropping multiple types with schema.dropType(), cascade.

  • Add alter type query support.

MySQL

  • Allow expressions in unique constraint

  • Add support for dropping temporary tables with temporary() modifier

  • Add addIndex to CreateTableBuilder

MSSQL

  • Add datetime2 data type support.

PGlite

  • Add PGlite dialect.

CICD & Tooling

  • Add dependabot.

Breaking Changes

  • Breaking

    Migrator, FileMigrationProvider and other migration related things are now exported from 'kysely/migration'. Importing from 'kysely' will provide an informative error message at compilation time.

    -import { Migrator, FileMigrationProvider } from 'kysely'
    +import { Migrator, FileMigrationProvider } from 'kysely/migration'
  • Breaking

    Minimum TypeScript version is now 5.4. Versions 5.3 and older will get a very aggressive compilation error.

  • Breaking

    The library no longer ships CommonJS files. Use a Node.js version that supports require(esm), or use dynamic imports. ES Modules files have moved from /dist/esm/ to /dist/.

  • Breaking

    TypeScript build target was bumped to 'es2023'.

  • Breaking

    sql.value and sql.literal were removed after spending a long time in deprecation. Use sql.val and sql.lit instead.

  • Breaking

    db.executeQuery's queryId 2nd argument has been replaced with options?: AbortableQueryOptions after spending a long time in deprecation.

  • Breaking

    QueryResult.numUpdatedOrDeletedRows has been removed after spending a long time in deprecation. Dialects that use it need to be updated to use QueryResult.numAffectedRows instead.

  • Breaking

    UniqueConstraintNode.columns widened from ReadonlyArray<ColumnNode> to ReadonlyArray<OperationNode>.

  • Breaking

    ExpressionBuilder.withSchema has been removed after spending a long time in deprecation.

  • Breaking

    DatabaseIntrospector.getMetadata has been removed after spending a long time in deprecation. Use DatabaseIntrospector.getTables instead.

  • Breaking

    MssqlDialectConfig.Tedious.resetConnectionOnRelease has been removed after spending a long time in deprecation. Use MssqlDialectConfig.resetConnectionsOnRelease instead.

  • Breaking

    MssqlDialectConfig.Tarn.options.validateConnections has been removed after spending a long time in deprecation. Use MssqlDialectConfig.validateConnections instead.

  • Breaking

    InsertQueryNode.ignore has been removed after spending a long time in deprecation. Use InsertQueryNode.orAction instead.

  • Breaking

    PrimaryConstraintNode has been removed after spending a long time in deprecation. Use PrimaryKeyConstraintNode instead.

  • Breaking

    DropTablexNodeParams has been removed after spending a long time in deprecation. Use DropTableNodeParams instead.

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.