Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
0.28.0 source code.tar.gz | 2025-04-13 | 17.1 MB | |
0.28.0 source code.zip | 2025-04-13 | 17.4 MB | |
README.md | 2025-04-13 | 10.1 kB | |
Totals: 3 Items | 34.5 MB | 0 |
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:
:::ts
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:
:::ts
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:
:::ts
{
"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:
:::ts
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. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1064- Speedup types with huge databases. Fixes https://github.com/kysely-org/kysely/issues/867 by @koskimas in https://github.com/kysely-org/kysely/pull/1080
- implement missing expression features by @koskimas in https://github.com/kysely-org/kysely/pull/1085
- Remove preventAwait by @wirekang in https://github.com/kysely-org/kysely/pull/1160
- add
ControlledTransaction
. by @igalklebanov in https://github.com/kysely-org/kysely/pull/962 & https://github.com/kysely-org/kysely/pull/1193 await using kysely = new Kysely()
support. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1167- feat: add HandleEmtpyInListsPlugin. by @austinwoon and @igalklebanov in https://github.com/kysely-org/kysely/pull/925
- Add Date as a valid return type for max and min by @samclearman & @igalklebanov in https://github.com/kysely-org/kysely/pull/1062
- Add support for cross join and cross join lateral by @ersinakinci in https://github.com/kysely-org/kysely/pull/1325
- dry up joins. by @igalklebanov in https://github.com/kysely-org/kysely/commit/c95f499c49d39342b2d259ea24a3a704a1dda336
- revisiting orderBy - deprecations, new order by item builder (nullFirst(), nullsLast(), collate()). by @igalklebanov in https://github.com/kysely-org/kysely/pull/1326
- add
queryId
toCompiledQuery
and all transformer methods. by @igalklebanov in https://github.com/kysely-org/kysely/pull/176 - feat: Add disableTransactions option to Migrator by @reidswan in https://github.com/kysely-org/kysely/pull/1335
- Redundant export UpdateValuesNode removed by @Ciantic in https://github.com/kysely-org/kysely/pull/1379
- Fix ctrl transaction mutation issues by @koskimas in https://github.com/kysely-org/kysely/pull/1406
- feat: escape single quotes in string literals. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1392
PostgreSQL π / MySQL π¬
- feat: Allow read-only transactions in Postgres and MySQL by B4nan in https://github.com/kysely-org/kysely/pull/1342 & https://github.com/kysely-org/kysely/pull/1350
PostgreSQL π / MS SQL Server π₯
- Add within group clause support for aggregate function builder by @ivashog in https://github.com/kysely-org/kysely/pull/1024
PostgreSQL π / SQLite π
- add support for deferrable constraints. by @koskimas in https://github.com/kysely-org/kysely/pull/1407
PostgreSQL π
- feat: support refresh materialized view by @QuentinJanuel in https://github.com/kysely-org/kysely/pull/990
- add
returning
support inMERGE
queries. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1171 - Support json_agg(column_ref) by @SimonSimCity in https://github.com/kysely-org/kysely/pull/1316
- feat: expands limit in select accepting null value by @alenap93 in https://github.com/kysely-org/kysely/pull/1347
- feat: make create type as enum values argument readonly. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1390
- add support for constraint renaming. by @koskimas in https://github.com/kysely-org/kysely/pull/1408
MySQL π¬
- Support update table1, table2, ... query support. Closes [#192] by @koskimas in https://github.com/kysely-org/kysely/pull/1079
MS SQL Server π₯
- Add outer and cross apply (mssql) by @drew-marsh in https://github.com/kysely-org/kysely/pull/1074
- refactor: extract
validateConnections
andresetConnectionsOnRelease
to root of config, flip defaultresetConnectionsOnRelease
behavior. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1388
SQLite π
- SQLite's OR CONFLICT clause for inserts by @vincentiusvin & @igalklebanov in https://github.com/kysely-org/kysely/pull/976
π Bugfixes
- fix: no logging in streams. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1382
- fix: ImmediateValueTransformer not handling PrimitiveValueListNodes. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1396
- fix: allow empty array for sql.join by @Sealos in https://github.com/kysely-org/kysely/pull/1395
PostgreSQL π
- fix: postgres auto increment introspection is wrong after column renames. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1391
π Documentation
- add reusable helpers recipe by @koskimas in https://github.com/kysely-org/kysely/pull/1085
- fix jsdocs. by @igalklebanov in https://github.com/kysely-org/kysely/commit/1c5e03ad79caad56f913a63e771cf31d1ba43793
π¦ CICD & Tooling
- ci: run 22.x by @igalklebanov in https://github.com/kysely-org/kysely/commit/9736aeb01633b05f30809758dfa9fa90e5da03ef
- chore: enforce min TS version by @igalklebanov in https://github.com/kysely-org/kysely/pull/1194
- fix package-lock. by @igalklebanov in https://github.com/kysely-org/kysely/commit/f348dfb9fb6da31f479997531bb045a4c5e9c4cb
- add TypeScript benchmarks. by @igalklebanov in https://github.com/kysely-org/kysely/pull/1314
- improve join tests dialect coverage. by @igalklebanov in https://github.com/kysely-org/kysely/commit/6eaf75496ed4acc183546808ff643f570e956fe9
- minor ci tweaks. by @igalklebanov in https://github.com/kysely-org/kysely/commit/ca1163220d171cfb9f571a754498899b6dc55b9b
β οΈ Breaking Changes
InferResult
now outputsInsertResult[]
,UpdateResult[]
,DeleteResult[]
,MergeResult[]
, instead ofInsertResult
,UpdateResult
,DeleteResult
,MergeResult
. To get the singular form, usetype Result = InferResult<T>[number]
.- Some generic/wide usages of
QueryCreator
's methods should no longer pass type checks. We never supported these officially. - As
preventAwait
is now removed on all builders, you must avoid awaiting builders without callingexecute
-like methods on your own. - TypeScript versions 4.5 and older are no longer supported. You will get an immediate compilation error telling you to upgrade.
QueryResult.numUpdatedOrDeletedRows
has been removed (after spending ~2 years in deprecation). We still log a warning. Outdated dialects that don't useQueryResult.numAffectedRows
should be updated OR forked.DefaultQueryExecutor.compileQuery
now requires passing aqueryId
argument. Use the newly exportedcreateQueryId()
as that argument value from now on.UpdateValuesNode
type has been removed.MssqlDialectConfig.tedious.resetConnectionOnRelease
has been deprecated, and had it's default flipped tofalse
. UseMssqlDialectConfig.resetConnectionsOnRelease
instead.MssqlDialectConfig.tarn.options.validateConnections
has been deprecated. UseMssqlDialectConfig.validateConnections
instead.- String literals are now
'
injection protected, hopefully. Please report any issues.
π€ New Contributors
- @QuentinJanuel made their first contribution in https://github.com/kysely-org/kysely/pull/990
- @austinwoon made their first contribution in https://github.com/kysely-org/kysely/pull/925
- @samclearman made their first contribution in https://github.com/kysely-org/kysely/pull/1062
- @drew-marsh made their first contribution in https://github.com/kysely-org/kysely/pull/1074
- @SimonSimCity made their first contribution in https://github.com/kysely-org/kysely/pull/1316
- @ersinakinci made their first contribution in https://github.com/kysely-org/kysely/pull/1325
- @reidswan made their first contribution in https://github.com/kysely-org/kysely/pull/1335
- @B4nan made their first contribution in https://github.com/kysely-org/kysely/pull/1342
- @Ciantic made their first contribution in https://github.com/kysely-org/kysely/pull/1379
- @Sealos made their first contribution in https://github.com/kysely-org/kysely/pull/1395
Full Changelog: https://github.com/kysely-org/kysely/compare/0.27.6...0.28.0