Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.28 #1278

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft

v0.28 #1278

wants to merge 28 commits into from

Conversation

igalklebanov
Copy link
Member

@igalklebanov igalklebanov commented Nov 24, 2024

Hey 👋

(changes since last edit: 74aed5d...v0.28)

It's been a long time coming, and now you can finally start transactions, and commit or roll them back manually!

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

PostgreSQL 🐘 / MS SQL Server 🥅
PostgreSQL 🐘
MySQL 🐬
MS SQL Server 🥅
SQLite 📘

🐞 Bugfixes

📖 Documentation

📦 CICD & Tooling

⚠️ Breaking Changes

  • InferResult now outputs InsertResult[], UpdateResult[], DeleteResult[], MergeResult[], instead of InsertResult, UpdateResult, DeleteResult, MergeResult. To get the singular form, use type 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 calling execute-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 use QueryResult.numAffectedRows should be updated OR forked.
  • DefaultQueryExecutor.compileQuery now requires passing a queryId argument. Use the newly exported createQueryId() as that argument value from now on.

🐤 New Contributors

Full Changelog: master...v0.28

Copy link

vercel bot commented Nov 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kysely ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 1, 2025 2:02pm

Copy link

pkg-pr-new bot commented Nov 24, 2024

Open in Stackblitzkysely_koa_example

npm i https://pkg.pr.new/kysely-org/kysely@1278

commit: 74aed5d

@belgattitude
Copy link

Btw thank you so much for the work you’re doing. Started using kysely and was really impressed !

congrats 🙌

@koskimas
Copy link
Member

@igalklebanov Feel free to merge this when you feel it's ready. I simply don't have the time right now to review. I trust you. Let me know when you want me to publish to npm.

@igalklebanov
Copy link
Member Author

Hey @koskimas 👋

Just parked it here to run CI (tests and preview release).
I wanna see if possible to add another long awaited feature before finalizing the list - and maybe some community PRs.

@cseickel
Copy link

cseickel commented Jan 3, 2025

@igalklebanov do you have any estimate on when v0.28 will be released? I'm itching to try out the performance improvements.

@igalklebanov
Copy link
Member Author

igalklebanov commented Jan 3, 2025

@igalklebanov do you have any estimate on when v0.28 will be released? I'm itching to try out the performance improvements.

We have preview releases. Try today.

npm i https://pkg.pr.new/kysely-org/kysely@1278

@flodlc
Copy link

flodlc commented Jan 4, 2025

@igalklebanov, thanks for the preview release.
Just tried it, I got JavaScript heap out of memory with 4gb allowed after a time approximately equal or higher than successful typecheck on version 0.27.4.
What time improvements should we expect? Is it an issue you already encountered?

Edit: with 8gb it works but I don't see any typecheck perf improvements on my side. I have around 60 tables and large codebase.

@igalklebanov igalklebanov linked an issue Jan 4, 2025 that may be closed by this pull request
@igalklebanov
Copy link
Member Author

igalklebanov commented Jan 4, 2025

@flodlc your comment is not actionable. Please submit a new issue with some traces, numbers, minimal reproduction, tsconfigs, TypeScript version, etc.

wirekang and others added 20 commits January 19, 2025 11:39
Co-authored-by: Igal Klebanov <[email protected]>
* feat: empty where in plugin

* test: add new tests

* chore: remove unneccesary typeguards

* fix: change to binary operator node

* test: update tests to do both in and not in

* test: for having

* chore: rm test

* test: nullable tests

* chore: nit

* chore: condense suite

* chore: db config override

* chore: extra console log

* chore: empty arr plugin docs

* HandleEmptyInListsPlugin initial commit.

Co-authored-by: Austin Woon Quan <[email protected]>

---------

Co-authored-by: Austin Woon <[email protected]>
Co-authored-by: igalklebanov <[email protected]>
remove only.
Co-authored-by: vincentiusvin <[email protected]>
Co-authored-by: Igal Klebanov <[email protected]>
Co-authored-by: Ivashkin Olexiy <[email protected]>
Co-authored-by: Dev K0te <[email protected]>
Co-authored-by: igalklebanov <[email protected]>
Co-authored-by: Drew Marshall <[email protected]>
Co-authored-by: Drew Marshall <[email protected]>
Co-authored-by: igalklebanov <[email protected]>
Co-authored-by: Simon Schick <[email protected]>
Co-authored-by: Igal Klebanov <[email protected]>
@flodlc
Copy link

flodlc commented Jan 25, 2025

@flodlc your comment is not actionable. Please submit a new issue with some traces, numbers, minimal reproduction, tsconfigs, TypeScript version, etc.

@igalklebanov Ok, I'll open an issue with a maximum of information soon and try to isolate the problem. What I can say for now is that there are cases (mine) where 0.28 break the typechecking performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Includes breaking changes major-release
Projects
None yet