Skip to content

Releases: kysely-org/kysely

0.28.3

18 Jul 01:17
Compare
Choose a tag to compare

Hey πŸ‘‹

A small batch of bug fixes. Please report any issues. 🀞😰🀞

πŸš€ Features

CockroachDB 🟣
  • fix: filter out internal cockroachdb schemas in postgres introspector by @yawhide in #1459

🐞 Bugfixes

  • fix(Migrator): NO_MIGRATIONS comparison fails in dup Kysely scenarios. by @igalklebanov in #1475
  • Fix Kysely<any> type errors with narrow table name types by @koskimas in #1443
  • fix AsyncDisposable usage erroring for older TypeScript versions. by @igalklebanov in #1507
  • fix(helpers): JSON helpers' return types incorrectly have Dates and other JS/Node-native instances that require data type metadata. by @igalklebanov in #1477
MySQL 🐬 / MS SQL Server πŸ₯…
  • fix: bigint immediates are appended as string literals instead of numbers. by @igalklebanov in #1445
MS SQL Server πŸ₯…

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: 0.28.2...v0.28.3

0.28.2

24 Apr 10:32
Compare
Choose a tag to compare

Hey πŸ‘‹

v0.28 broke an undocumented TypeScript behavior our API had that allowed you to pass table name unions to query builders and enable some DRYing of queries. Seeing that this pattern was quite popular, we decided to support it officially with the addition of the table method in the dynamic module.

You can pull off some crazy complex stuff like:

async function getRowByColumn<
  T extends keyof Database,
  C extends keyof Database[T] & string,
  V extends SelectType<Database[T][C]>,
>(t: T, c: C, v: V) {
  // We need to use the dynamic module since the table name
  // is not known at compile time.
  const { table, ref } = db.dynamic

  return await db
    .selectFrom(table(t).as('t'))
    .selectAll()
    .where(ref(c), '=', v)
    // `id` can be directly referenced since every table has it.
    .orderBy('t.id')
    .executeTakeFirstOrThrow()
}

const person = await getRowByColumn('person', 'first_name', 'Arnold')

...and it'll narrow the downstream query context to the intersection of all the possible shapes of tables in the union type. (DONT DO THIS AT HOME KIDS!)

A simpler example would be:

async function deleteItem(id: string, table: 'person' | 'pet') {
  await db
    .deleteFrom(db.dynamic.table(table).as('t'))
    .where('id', '=', id)
    .executeTakeFirstOrThrow()
}

If you attempt to refer to a column that doesn't exist in both "person" and "pet" (e.g. "pet"'s "species" column), the compiler will correctly yell at you.

πŸš€ Features

  • Add table to DynamicModule for dynamic table references by @koskimas in #1434

🐞 Bugfixes

SQLite πŸ“˜
  • fix: SQLite's introspector is printing deprecation errors for orderBy(array). by @igalklebanov in #1435

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: 0.28.1...0.28.2

0.28.1

19 Apr 10:41
Compare
Choose a tag to compare

Hey πŸ‘‹

Just a small crucial bug fix release. Please inform us if you see any more regressions since v0.28. πŸ™

πŸš€ Features

🐞 Bugfixes

PostgreSQL 🐘
  • pg introspector - Wrap schema.table in double quotes for case handling by @neil176 in #1426

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: 0.28.0...0.28.1

0.28.0

13 Apr 05:52
Compare
Choose a tag to compare

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

PostgreSQL 🐘 / MySQL 🐬
  • feat: 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 by @ivashog in #1024
PostgreSQL 🐘 / SQLite πŸ“˜
PostgreSQL 🐘
MySQL 🐬
MS SQL Server πŸ₯…
  • Add outer and cross apply (mssql) by @drew-marsh in #1074
  • refactor: extract validateConnections and resetConnectionsOnRelease to root of config, flip default resetConnectionsOnRelease behavior. by @igalklebanov in #1388
SQLite πŸ“˜

🐞 Bugfixes

PostgreSQL 🐘
  • fix: postgres auto increment introspection is wrong after column renames. by @igalklebanov in #1391

πŸ“– 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.
  • UpdateValuesNode type has been removed.
  • MssqlDialectConfig.tedious.resetConnectionOnRelease has been deprecated, and had it's default flipped to false. Use MssqlDialectConfig.resetConnectionsOnRelease instead.
  • MssqlDialectConfig.tarn.options.validateConnections has been deprecated. Use MssqlDialectConfig.validateConnections instead.
  • String literals are now ' injection protected, hopefully. Please report any issues.

🐀 New Contributors

Full Changelog: 0.27.6...0.28.0

0.27.6

03 Mar 18:38
Compare
Choose a tag to compare

Hey πŸ‘‹

v0.28 is right around the corner! πŸ‘€

πŸš€ Features

🐞 Bugfixes

  • fix: implements a underscore validation to camelcase plugin by @rhyzzor in #1290
  • fix: resolve edge case with varying shapes in multiple item inserts causing undefined in parameters. by @naorpeled & @igalklebanov in #1311
PostgreSQL 🐘
  • Use JS sort method to sort migrations by name by @DavesBorges in #844
  • fix: WithSchemaPlugin is adding schema to table function arguments and causes db errors in json_agg and to_json. by @igalklebanov in #827
SQLite πŸ“˜

πŸ“– Documentation

PostgreSQL 🐘

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: 0.27.5...0.27.6

0.27.5

08 Dec 12:05
Compare
Choose a tag to compare

Hey πŸ‘‹

Long-time community member and ambassador @thelinuxlich has joined the contributors club! πŸ…

v0.28 is right around the corner! πŸ‘€

πŸš€ Features

PostgreSQL 🐘 / MySQL 🐬 / SQLite πŸ“˜
  • Add orderBy clause support to aggregate function builder by @ivashog in #896
PostgreSQL 🐘 / MySQL 🐬
  • Adds onReserveConnection to Postgres and MySQL dialect configs by @dcousineau in #996
PostgreSQL 🐘
MS SQL Server πŸ₯…
  • Add additional config options to MSSQL dialect by @tmrclark in #1073

🐞 Bugfixes

  • Updated TraversedJSONPathBuilder.$castTo and .$notNull to support chaining with .as() by @cassus in #1139
  • DeduplicateJoinsPlugin preserves order of joins by @sam-lewis-storyteq in #1156

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: 0.27.4...0.27.5

0.27.4

06 Jul 23:35
Compare
Choose a tag to compare

Hey πŸ‘‹

We've reached 100 contributors AND 1,000 pull requests since our last release! 🍾
Here's all the amazing work done since version 0.27.3...

πŸš€ Features

  • Added clearGroupBy() by @dswbx in #921
  • add objectStrategy option that allows to not mutate result objects/arrays @ ParseJSONResultsPlugin. by @igalklebanov in #953
PostgreSQL 🐘 / SQLite πŸ“˜
  • Support table names in UpdateQueryBuilder.returningAll by @koskimas in f63327e
MySQL 🐬 / MS SQL Server πŸ₯…
PostgreSQL 🐘
MS SQL Server πŸ₯…

🐞 Bugfixes

  • move preventAwait to alter-column-builder.ts. by @igalklebanov in #1031
  • fixes The type of eb in selectFrom(eb => ...) is wrong by @koskimas in 873671b
  • fixes QueryCompilerError: Could not serialize value causes Kysely instance to fail later by @koskimas in a65a7f3
  • fixes CamelCasePlugin messes up complex type mappings with setTypeParser by @koskimas in d45a8fa
PostgreSQL 🐘 / MS SQL Server πŸ₯…
PostgreSQL 🐘
MS SQL Server πŸ₯…

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: 0.27.3...0.27.4

0.27.3

27 Apr 12:59
Compare
Choose a tag to compare

Hey πŸ‘‹

This release happened on 03/09/2024.

What's Changed

Breaking Changes:

  • into is now optional in InsertQueryNode.
  • table is now optional in UpdateQueryNode.
  • column data types are now validated at runtime. This only affects users who passed unsupported strings in the past. In case Kysely doesn't offer built-in support for a specific data type, you should have then and still should use sql template tag.

New Contributors

Full Changelog: 0.27.2...0.27.3

0.27.2

06 Jan 10:27
Compare
Choose a tag to compare
  • Add allowUnorderedMigrations option for the migrator. #723 Awesome work by @tracehelms ❀️
  • Fix update and insert query type issues when using Kysely<any>.
  • Improve error messages when passing a wrong column name or wrong type for a column in UpdateQueryBuilder#set and InsertQueryBuilder#values methods.

0.27.1

02 Jan 10:52
Compare
Choose a tag to compare
  • Add $notNull type helper
  • Support for update of table and friends #683
  • Support insert into "person" default values #685
  • Support arbitrary expressions in limit and offset
  • Support insert, update and delete queries in raw SQL substitutions #680
  • Fix node 14 regression #824
  • Fix fn.agg regression where two type arguments were required #829