| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| 0.29.0 source code.tar.gz | 2026-05-08 | 15.0 MB | |
| 0.29.0 source code.zip | 2026-05-08 | 15.3 MB | |
| README.md | 2026-05-08 | 13.4 kB | |
| Totals: 3 Items | 30.3 MB | 0 | |
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!
:::ts
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!
:::ts
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!
:::ts
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!
:::ts
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.
:::ts
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.
:::ts
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.
:::ts
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
- feat(utils): Allow explicit undefined in Updateable type (for exactOptionalPropertyTypes support) by @y-hsgw in https://github.com/kysely-org/kysely/pull/1496
- feat(migrator): allow disabling transactions in migrate methods. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1517
- feat: add
thenRefmethod ineb.caseby @ericsodev in https://github.com/kysely-org/kysely/pull/1531 - feat: add
whenRef(lhs, op, rhs)ineb.case. by @iam-abdul in https://github.com/kysely-org/kysely/pull/1598 - feat: add
elseRefineb.case()by @iam-abdul in https://github.com/kysely-org/kysely/pull/1601 - feat: add
$pickTables,$omitTablesand$extendTables, deprecatewithTables. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1582 - feat: add
SafeNullComparisonPluginplugin by @rafaelalmeidatk in https://github.com/kysely-org/kysely/pull/1338 - feat: add more control through configuration @
ParseJSONResultsPlugin. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1453 - feat: allow expressions in create/add index's
columnandcolumnsfunctions, deprecate theirexpressionfunctions. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1664 - feat: add
with(name, query). by @igalklebanov in https://github.com/kysely-org/kysely/pull/1702 - feat: expose migrations from 'kysely/migration'. deprecate migration exports in root. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1618
- refactor: bump minimum TypeScript version to 4.7. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1696
- refactor: bump minimum TypeScript version to 4.8. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1756
- refactor: bump minimum TypeScript version to 4.9. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1759
- refactor: bump minimum TypeScript version to 5.0. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1761
- refactor: bump minimum TypeScript version to 5.1. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1770
- refactor: bump minimum TypeScript version to 5.2. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1771
- refactor: bump minimum TypeScript version to 5.3. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1772
- refactor: bump minimum TypeScript version to 5.4. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1773
- feat: support narrowing by deep object keys in
NarrowPartialby @ethanresnick in https://github.com/kysely-org/kysely/pull/1667 - feat: add
ReadonlyKysely<DB>helper. by @igalklebanov in https://github.com/kysely-org/kysely/pull/218 - refactor: replace
requireAllProps<T>(obj)usage withsatisfies AllProps<T>. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1787 - feat: allow overriding file import function @
FileMigrationProvider. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1661 - feat: query cancellation. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1796 & https://github.com/kysely-org/kysely/pull/1797 & https://github.com/kysely-org/kysely/pull/1798 & https://github.com/kysely-org/kysely/commit/33e60dfa6284263173ee7e678455ad410f8bf246 & https://github.com/kysely-org/kysely/commit/b739e0240cd885091508335ce16461da258c47f6 & https://github.com/kysely-org/kysely/commit/4d7064f199bd107213597a5965c4d673ab9880a2
PostgreSQL ๐ / MySQL ๐ฌ
- feat(Introspect): add support for postgres & mysql foreign tables by @williamluke4 in https://github.com/kysely-org/kysely/pull/1494
PostgreSQL ๐ / MSSQL ๐ฅ
- feat(Migrator): allow passing transactions to
Migrator. by @jlucaso1 in https://github.com/kysely-org/kysely/pull/1480 - feat: support IF EXISTS in DROP COLUMN by @shuaixr in https://github.com/kysely-org/kysely/pull/1692
PostgreSQL ๐
- feat: support dropping multiple types with schema.dropType(), cascade. by @aantia in https://github.com/kysely-org/kysely/pull/1516
- feat: add alter type query support. by @lucianolix in https://github.com/kysely-org/kysely/pull/1363
MySQL ๐ฌ
- feat: allow expressions in unique constraint by @ericsodev in https://github.com/kysely-org/kysely/pull/1518
- feat: Add support for dropping temporary tables with temporary() modifier by @szalonna in https://github.com/kysely-org/kysely/pull/1615
- feat: add
addIndextoCreateTableBuilderby @alenap93 in https://github.com/kysely-org/kysely/pull/1352
MSSQL ๐ฅ
- feat: add
datetime2data type support. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1792
PGlite ๐จ
- feat: add PGlite dialect. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1510
๐ Bugfixes
๐ Documentation
๐ฆ CICD & Tooling
- chore: improve TypeScript benchmarks. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1757
- chore: add returning.bench.ts by @igalklebanov in https://github.com/kysely-org/kysely/commit/65b6ec4abe15101ea2fad61e01b89fecf762ad40
- chore: enhance returning benchmarks. by @igalklebanov in https://github.com/kysely-org/kysely/commit/b23085acc23f3aeaa2764006ca327bc72919d108
- chore: add selectNoFrom benchmarks. @igalklebanov in https://github.com/kysely-org/kysely/commit/8193d3716dea0a8c0a93e882cc0450966900073e
- test: fix TypeScript 5.4.0 test following target bump to es2023. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1780
- chore: drop CommonJS distribution. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1782
- chore(ci): support rc publishes from next branch. by @igalklebanov in https://github.com/kysely-org/kysely/commit/585bf60c6d93cf01db39e196be32f12a2c8a7f01
โ ๏ธ Breaking Changes
Migrator,FileMigrationProviderand other migration related things are now exported from'kysely/migration'. Importing from'kysely'will provide an informative error message at compilation time.
diff
-import { Migrator, FileMigrationProvider } from 'kysely'
+import { Migrator, FileMigrationProvider } from 'kysely/migration'
-
Minimum TypeScript version is now 5.4. Versions 5.3 and older will get a very aggressive compilation error.
-
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/. -
TypeScript build target was bumped to
'es2023'. -
sql.valueandsql.literalwere removed after spending a long time in deprecation. Usesql.valandsql.litinstead. -
db.executeQuery'squeryId2nd argument has been replaced withoptions?: AbortableQueryOptionsafter spending a long time in deprecation. -
QueryResult.numUpdatedOrDeletedRowshas been removed after spending a long time in deprecation. Dialects that use it need to be updated to useQueryResult.numAffectedRowsinstead. -
UniqueConstraintNode.columnswidened fromReadonlyArray<ColumnNode>toReadonlyArray<OperationNode>.
๐ค New Contributors
- @y-hsgw made their first contribution in https://github.com/kysely-org/kysely/pull/1496
- @williamluke4 made their first contribution in https://github.com/kysely-org/kysely/pull/1494
- @ericsodev made their first contribution in https://github.com/kysely-org/kysely/pull/1518
- @aantia made their first contribution in https://github.com/kysely-org/kysely/pull/1516
- @iam-abdul made their first contribution in https://github.com/kysely-org/kysely/pull/1598
- @szalonna made their first contribution in https://github.com/kysely-org/kysely/pull/1615
- @rafaelalmeidatk made their first contribution in https://github.com/kysely-org/kysely/pull/1338
- @jlucaso1 made their first contribution in https://github.com/kysely-org/kysely/pull/1480
- @lucianolix made their first contribution in https://github.com/kysely-org/kysely/pull/1363
- @shuaixr made their first contribution in https://github.com/kysely-org/kysely/pull/1692
Full Changelog: https://github.com/kysely-org/kysely/compare/v0.28.17...v0.29.0