Skip to content

Releases: kysely-org/kysely

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...master

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

0.27.0

30 Dec 12:14
Compare
Choose a tag to compare
  • Add mssql dialect. A huge effort by @igalklebanov ❤️ #595
  • Add postgres json_agg and to_json functions to function module
  • Add is distinct from operator #673
  • Add set('first_name', 'Jennifer') variant for update query's set method #672
  • Add as statement support for createTable #771. Thank you @viraxslot ❤️
  • Add nulls not distinct option for constraints #770. Thank you @viraxslot ❤️
  • Add addIndex & dropIndex @ AlterTableBuilder #720. Thank you @Gaspero
  • Add stream() support for sqlite dialect #754. Thank you @tgriesser ❤️
  • Fix query and error logging both occur on error. #796. Thank you @igalklebanov ❤️
  • Fix type issue with $if #793. Thank you @igalklebanov ❤️
  • Fix issue where onConflict..doUpdateSet used select types instead of update types. #792. Thank you @igalklebanov ❤️
  • Add eb.jsonPath<$> #791. Thank you @igalklebanov ❤️
  • $narrowType supports new type tag NotNull for an easier way to mark columns not nullable manually
  • Fix #811
  • Support arbitrary expressions in min and max aggregate functions.

Breaking changes

  • selectNoFrom is removed from ExpressionBuilder due to severe typescript performance issues. selectNoFrom still exists in the Kysely instance, and in most cases, you can use that instead. See this example on how to migrate: https://kyse.link/?p=s&i=sqAZIvTQktxgXYzHGkqX.
  • Types are once again a little bit stricter in some places. You might get type errors from code like where('first_name', '=', sql`something`). You need to explicitly give a type for sql expressions like this sql<string>`something`
  • Deprecated functions eb.cmpr and eb.bxp have been removed. Use eb as a function instead.

0.26.3

27 Aug 11:53
Compare
Choose a tag to compare
  • Type performance improvements. We got ~30% speedup in our type test suite. Results will vary.
  • Fix autocompletion issues select(eb => [autocompletion works here now]).

0.26.2

25 Aug 18:08
Compare
Choose a tag to compare
  • Added support for select statements without a from clause. The function is called selectNoFrom. The function name was selected after a lot of discussion. The most natural name would just be select, but new users would find that in a list of autocompletions before selectFrom and naturally use it when trying to create a select from query. This would be especially true for people coming from knex where a select from query is started using a select call. #605
  • Add object variants of and and or functions. Allows easy where(eb => eb.and(object)) filters. #583
  • Add support for tuples. See some examples here. #611
  • Add addPrimaryKeyConstraint for AlterTableBuilder. #639 Thank you @n7olkachev ❤️
  • Add any function to function module. #612
  • Add between method to expression builder. #602
  • Add lit method to expression builder. #600
  • Add multi-column variant of orderBy. #423 Thank you @igalklebanov ❤️

An example of an object and call:

const persons = await db
  .selectFrom('person')
  .selectAll()
  .where((eb) => eb.and({
    first_name: 'Jennifer',
    last_name: eb.ref('first_name')
  }))
  .execute()
select * from "person"
where "first_name" = $1 and "last_name" = "first_name"

0.26.0

07 Jul 17:00
Compare
Choose a tag to compare

Expression builder improvements

We improved the expression builder based on excellent feedback from the community in this issue in addition to many discord discussions. Unfortunately this means deprecating the recently added cmpr and bxp methods, but the migration should be painless. Read more @ #565.

Before you could create comparisons and arbitrary binary expressions using cmpr and bxp respectively:

where((eb) => eb.or([
  eb.cmpr('first_name', '=', 'Jennifer'),
  eb.cmpr('first_name', '=', 'Sylvester'),
]))

set((eb) => ({
  age: eb.bxp('age', '+', 1)
}))

After this release, you'd do this instead:

where((eb) => eb.or([
  eb('first_name', '=', 'Jennifer'),
  eb('first_name', '=', 'Sylvester'),
]))

set((eb) => ({
  age: eb('age', '+', 1)
}))

As you can see we made the expression builder callable and it can create all kinds of binary expressions. You can still use destructuring as before since the expression builder has a new property eb that returns itself:

where(({ eb, or }) => or([
  eb('first_name', '=', 'Jennifer'),
  eb('first_name', '=', 'Sylvester'),
]))

or and and chaining

We've also added new way to create and and or expressions using chaining

where((eb) => 
  eb('first_name', '=', 'Jennifer').or('first_name', '=', 'Sylvester')
]))

The old and and or methods are still there and are not going anywhere.

JSON references

The expression builder's ref function can now be used to reference nested JSON columns' fields and array items in a type-safe way:

// Postgres syntax: "addresses"->0->'postalCode'
where(({ eb, ref }) =>
  eb(ref('addresses', '->').at(0).key('postalCode'), '=', '61710')
)

// MySQL syntax: `addresses`->'$[0].postalCode'
where(({ eb, ref }) =>
  eb(ref('addresses', '->$').at(0).key('postalCode'), '=', '61710')
)

The JSON reference builder is just our first guess of a good API. We're eager to hear your feedback. More examples and a recipe on the subject will follow shortly after this release. Read more @ #440.

Other changes

  • fix onConflict compilation errors starting from TypeScript 5.1.6 #568. Thanks @igalklebanov ❤️
  • Add UpdateResult.numChangedRows. #431 Thanks @wirekang ❤️
  • Disallow AlterColumn method chaining. #468 Thanks @soanvig ❤️
  • Allow arbitrary expressions in count and sum
  • Allow parameters in raw sql. #512 Thanks @nicksrandall ❤️

0.25.0

27 May 08:33
Compare
Choose a tag to compare

Large amount of contributions from many awesome people in this one, but one definitely stands out:

Using his sorcerous knowledge of the typescript compiler internals @schusovskoy was able to significantly reduce the possibility of the notorious Type instantiation is excessively deep and possibly infinite compiler error throughout Kysely. Check out the PR here #483 🧙. In our typing tests, we were able to at least double the complexity of the troublesome queries without hitting slowdowns or compiler errors. In some cases the issue seems to have gone away completely.

Simply amazing work. Thank you so much @schusovskoy ❤️

Other fixes and improvements in no particular order:

  • Add new case when then end builder #404. Thanks @igalklebanov ❤️
  • Allow specifying column sort order when creating indexes #375. Thanks @igalklebanov ❤️
  • Add $narrowType helper for narrowing the query output type #380. Thanks @igalklebanov ❤️
  • Make subquery selections nullable by default #420
  • Fix alter table schema handling #471. Thanks @hannesj ❤️
  • Add agg method to expression builder for arbitrary aggregate function calls #417 @igalklebanov ❤️
  • The $if method should no longer cause performance issues or excessively deep types
  • Make logger support async calls #425. Thanks @mehulmpt ❤️

In addition to this there were small fixes from multiple awesome people including: