Releases: kysely-org/kysely
0.27.5
Hey 👋
Long-time community member and ambassador @thelinuxlich has joined the contributors club! 🏅
v0.28 is right around the corner! 👀
🚀 Features
- add modifyEnd to insert, update and delete query builders by @thelinuxlich in #871
PostgreSQL 🐘 / MySQL 🐬 / SQLite 📘
PostgreSQL 🐘 / MySQL 🐬
- Adds
onReserveConnection
to Postgres and MySQL dialect configs by @dcousineau in #996
PostgreSQL 🐘
MS SQL Server 🥅
🐞 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
- Migrate to new playground by @wirekang in #861
- Improve relations recipe by @koskimas in #1081
- Improve expressions recipe by @koskimas in #1083
- fix: References typo by @Alcas1 in #1092
- Fix docs for
generatedAlwaysAs
by @nikeee in #1113 - chore: fix some comments by @timesince in #1114
- added clickhouse and bigquery dialects by @maktouch in #1117
- docs: updated outdated links by @krijoh92 in #1125
- Update migrations.mdx by @tijptjik in #1122
- fix: Raw builder typos by @Alcas1 in #1148
- docs: support light mode. by @igalklebanov in #1177
- docs: fix weird default state showing dark and light elements. by @igalklebanov in #1179
- fix(docs): add missing import to migrations example script by @mxkxf in #1178
- docs: refresh quotes. by @igalklebanov in #1182
- docs: fix stackblitz theme out of sync. by @igalklebanov in #1183
- docs: rework features list. by @igalklebanov in #1185
- docs:
MERGE
examples by @igalklebanov in #1188 - docs: add prerequisites section in "getting started". by @igalklebanov in #1197
- Docs: fix typo by @remiposo in #1216
- chore: check jsdoc examples. by @igalklebanov in #1263
- chore: fix jsdoc errors and add some examples, pt. 1. by @igalklebanov in #1264
- chore: fix jsdoc errors and add some examples, pt. 2. by @igalklebanov in #1277
- docs: clarify that after rolling back a transaction the exception gets thrown again by @twiddler in #1266
- chore: fix jsdoc errors and add some examples, pt. 3. by @igalklebanov in #1279
📦 CICD & Tooling
- chore: bump dependencies by @igalklebanov in #1126
- chore: run prettier. by @igalklebanov in #1128
- ci: test against older TypeScript versions. by @igalklebanov in #1192
- chore: add conditional exports test. by @igalklebanov in #1207
- chore: add continuous preview releases. by @igalklebanov in #1219
- Create .renovaterc.json by @igalklebanov in 3f99090
- chore: test deno 2. by @igalklebanov in #1262
- chore: check jsdoc examples. by @igalklebanov in #1263
⚠️ Breaking Changes
🐤 New Contributors
- @thelinuxlich made their first contribution in #871
- @dcousineau made their first contribution in #996
- @kansson made their first contribution in #1086
- @Alcas1 made their first contribution in #1092
- @timesince made their first contribution in #1114
- @krijoh92 made their first contribution in #1125
- @tijptjik made their first contribution in #1122
- @cassus made their first contribution in #1139
- @sam-lewis-storyteq made their first contribution in #1156
- @ivashog made their first contribution in #896
- @mxkxf made their first contribution in #1178
- @remiposo made their first contribution in #1216
- @twiddler made their first contribution in #1266
Full Changelog: 0.27.4...master
0.27.4
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 📘
MySQL 🐬 / MS SQL Server 🥅
- add varbinary data type for mysql by @jonasbovyn in #812
PostgreSQL 🐘
- feat: add 'add column if not exists' for postgres by @MarkusWendorf in #900
- feat: add '?|' comparison operator by @alenap93 in #1006
- feat: add the starts-with postgres comparison operator by @boehs in #1029
- postgres introspection getTables handle partition tables as well. by @HeikoOsigus in #1034
MS SQL Server 🥅
- add
OUTPUT
clause support. by @igalklebanov in #828
🐞 Bugfixes
- move
preventAwait
toalter-column-builder
.ts. by @igalklebanov in #1031 - fixes The type of
eb
inselectFrom(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 🥅
- Updating visitMergeQuery to join
WhenNode
s with a space by @gittgott in #940 - fix merge queries not being transformed. by @igalklebanov in #955
- fix
InferResult
not working for merge queries. by @igalklebanov in #902
PostgreSQL 🐘
- Fix typo on timetz regex by @dunkelbraun in #911
MS SQL Server 🥅
- fix
MssqlDialect
streaming not handling backpressure. by @igalklebanov in #1041 - fix Tedious v18 includes different TypeScript annotations by @igalklebanov in #1041
- handle connection errors @
MssqlDriver
. by @igalklebanov in #1042
📖 Documentation
- fix complex join example by @koskimas in 9f836c4
- fix complex join example some more by @koskimas in 8f9038f
- fix complex insert example by @koskimas in ead3489
- improve subquery insert example by @koskimas in 0e194b0
- add not null assertion site example by @koskimas in 58ba4ae
- fix a bunch of untyped sql snippets in API doc examples by @koskimas in 64a56f9
- make it even more clear that table interfaces are not row types by @koskimas in 9485b44
- update outdated intro in kysely.dev by @koskimas in e84863d
- remove snyk badge. by @igalklebanov in 4326a91
- add CTE examples to site by @koskimas in d9a53cd1441e0854456e930eb628f5b03a34db93\
- fix SQLite import @ getting started. by @igalklebanov in #927
- capitalization, more environments @ README. by @igalklebanov in 6ab2155
- fixed docs for deno by @kolay-v in #938
- Added MySQL and MariaDB support information for relation recipes by @chriswep in #800
- Fix spelling, punctuation, grammar by @DePasqualeOrg in #969
- Fix typo (it's --> its) by @davidalber in #1000
- add logging documentation page by @JeromeBu in #1003
- Docs now reflect
tedious
support inBun
by @igalklebanov in #1018 - Docs: Fix typo by @devgru in #1025
- mention
kysely-ctl
in migrations section. by @igalklebanov in #1035 - docs: add comments for
UpdateResult
by @movahhedi in #993 - fix mssql createPerson example. by @igalklebanov in #1048
- docs: fix values example not compiling. by @igalklebanov in #1058
- fix typo incorrect by @zce in #1068
📦 CICD & Tooling
- migrate to docker compose v2. by @igalklebanov in #932
- ci: bumping actions and runtimes. by @igalklebanov in #942
- ci: drop node16 tests as it reached EOL. by @igalklebanov in 873ed5a
- remove docker-compose file version. by @igalklebanov in #966
- add node22 @ tests. by @igalklebanov in #964
- export all operation nodes, forever. by @igalklebanov in #972
- ci: bump bun, test mssql in bun. by @igalklebanov in #1022
- ci: install only chromium by @igalklebanov in #1043
- bump TypeScript to v5.5. by @igalklebanov in #965
- docs: bump docusaurus to v3. by @igalklebanov in #1050
- docs: remove remaining react imports. by @igalklebanov in #1057
- ci: split jobs. by @igalklebanov in #943
⚠️ Breaking Changes
🐤 New Contributors
- @dunkelbraun made their first contribution in #911
- @dswbx made their first contribution in #921
- @kolay-v made their first contribution in #938
- @chriswep made their first contribution in #800
- @jonasbovyn made their first contribution in #812
- @DePasqualeOrg made their first contribution in #969
- @davidalber made their first contribution in #1000
- @JeromeBu made their first contribution in #1003
- @alenap93 made their first contribution in #1006
- @devgru made their first contribution in #1025
- @boehs made their first contribution in #1029
- @HeikoOsigus made their first contribution in #1034
- @movahhedi made their first contribution in #993
- @zce made their first contribution in #1068
Full Changelog: 0.27.3...0.27.4
0.27.3
Hey 👋
This release happened on 03/09/2024.
What's Changed
- add
cast
method toExpressionBuilder
. by @koskimas in 3df726f - fix bug in
ExtractTableAlias
exposed by TypeScript 5.4. by @koskimas in e356951 - add
MERGE
query support. by @igalklebanov in #700 - introspect column comments by @maktouch in #842
- Fix MSSQL Table Introspection Duplicate Column by @timclark97 in #848
- implement additional query builder clear methods by @garymathews in #840
- Just add missing smallint support for addColumn() (SIMPLE_COLUMN_DATA_TYPES) by @hash0000 in #860
- Correct spelling mistake in the case example by @obax in #878
- [Docs] Update complex join example to better illustrate the options available (symmetry with
where
) by @MarkusWendorf in #883 - add
IDENTITY
column support. by @igalklebanov in #823 - Add
LIMIT
operator for update statements by @tbui17 in #885 - add
FETCH
clause support. by @igalklebanov in #822 - add
TOP
clause support. by @igalklebanov in #821
Breaking Changes:
into
is now optional inInsertQueryNode
.table
is now optional inUpdateQueryNode
.- 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
- @maktouch made their first contribution in #842
- @timclark97 made their first contribution in #848
- @garymathews made their first contribution in #840
- @hash0000 made their first contribution in #860
- @obax made their first contribution in #878
- @tbui17 made their first contribution in #885
Full Changelog: 0.27.2...0.27.3
0.27.2
- 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
andInsertQueryBuilder#values
methods.
0.27.1
- Add
$notNull
type helper - Support
for update of table
and friends #683 - Support
insert into "person" default values
#685 - Support arbitrary expressions in
limit
andoffset
- 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
- Add mssql dialect. A huge effort by @igalklebanov ❤️ #595
- Add postgres
json_agg
andto_json
functions to function module - Add
is distinct from
operator #673 - Add
set('first_name', 'Jennifer')
variant for update query'sset
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 tagNotNull
for an easier way to mark columns not nullable manually- Fix #811
- Support arbitrary expressions in
min
andmax
aggregate functions.
Breaking changes
selectNoFrom
is removed fromExpressionBuilder
due to severe typescript performance issues.selectNoFrom
still exists in theKysely
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 forsql
expressions like thissql<string>`something`
- Deprecated functions
eb.cmpr
andeb.bxp
have been removed. Useeb
as a function instead.
0.26.3
0.26.2
- 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 beselect
, but new users would find that in a list of autocompletions beforeselectFrom
and naturally use it when trying to create aselect from
query. This would be especially true for people coming from knex where aselect from
query is started using aselect
call. #605 - Add object variants of
and
andor
functions. Allows easywhere(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
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
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:
- #499 #463 by @neographer
- #444 by @rafaumlemos
- #478 by @thdxr
- Work on kysely.dev by @wirekang and @naorpeled