Skip to content

Releases: kysely-org/kysely

0.28.8

09 Oct 21:47
v0.28.8
4daed49
Compare
Choose a tag to compare

Hey πŸ‘‹

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

πŸš€ Features

🐞 Bugfixes

PostgreSQL 🐘

  • fix: filter schemas the current user does not have access to in postres introspector by @chanon in #1550
  • fix: insert/update not being wrapped in parens when in CTE of a merge query. by @igalklebanov & @msifd in #1611

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: v0.28.7...v0.28.8

0.28.7

14 Sep 15:37
Compare
Choose a tag to compare

Hey πŸ‘‹

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

πŸš€ Features

🐞 Bugfixes

  • fix: unexported dynamic builders resulting in ts(2742) when composite: true. by @igalklebanov in #1578
  • fix(ExpressionBuilder): improper custom operator support in eb(). by @igalklebanov in #1579
  • fix(TransactionBuilder): auto rollback only if transaction begun. by @igalklebanov in #1580

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: v0.28.6...v0.28.7

0.28.6

13 Sep 10:59
Compare
Choose a tag to compare

Hey πŸ‘‹

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

Docs site has been optimized and all we got was this animation:

image

πŸš€ Features

🐞 Bugfixes

PostgreSQL 🐘 / MSSQL πŸ₯…

MySQL 🐬

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: v0.28.5...v0.28.6

0.28.5

10 Aug 18:22
Compare
Choose a tag to compare

Hey πŸ‘‹

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

πŸš€ Features

🐞 Bugfixes

  • fix: Buffer breaking ShallowDehydrateValue in non-Node.js TypeScript environments. by @igalklebanov in #1542.

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: v0.28.4...v0.28.5

0.28.4

02 Aug 01:21
Compare
Choose a tag to compare

Hey πŸ‘‹

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

πŸš€ Features

🐞 Bugfixes

  • fix: ShallowDehydrateValue mishandles null & undefined, and bigint / numeric strings. by @igalklebanov in #1529
PostgreSQL 🐘
  • Fix fn.any to support ColumnType references by @Ruthenz in #1521

πŸ“– Documentation

πŸ“¦ CICD & Tooling

⚠️ Breaking Changes

🐀 New Contributors

Full Changelog: v0.28.3...v0.28.4

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