Kysely (the type-safe SQL query builder for TypeScript) v0.29 is out btw

igalklebanov1 pts1 comments

Release 0.29.0 路 kysely-org/kysely 路 GitHub

//releases/show" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

//releases/show;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

kysely-org

kysely

Public

Notifications<br>You must be signed in to change notification settings

Fork<br>408

Star<br>13.8k

0.29.0

Compare

Choose a tag to compare

Sorry, something went wrong.

Filter

Loading

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

No results found

View all tags

igalklebanov

released this

08 May 23:54

&middot;

36 commits

to master<br>since this release

Immutable<br>release. Only release title and notes can be modified.

v0.29.0

820f722

This commit was signed with the committer鈥檚 verified signature .

igalklebanov<br>Igal Klebanov

SSH Key Fingerprint: 7bwYtuYFCy9qHvjjRM/MBl69ElqQUpig6W4XY9cVqDs<br>Verified

Learn about vigilant mode.

Hey 馃憢

This one's a banger! 馃挜 馃挜 馃挜

We got $pickTables, $omitTables compile-time helpers to narrow the world view of downstream queries, cutting down on compilation complexity/time while at it!

() // () // const results = await db<br>.$pickTables'person' | 'pet'>() // } for following methods.<br>.selectFrom('person')<br>.innerJoin('pet', 'pet.owner_id', 'person.id')<br>.selectAll()<br>.execute()

const results = await db<br>.$omitTables'toy'>() //<br>.selectFrom('person')<br>.innerJoin('pet', 'pet.owner_id', 'person.id')<br>.selectAll()<br>.execute()

We got a new ReadonlyKysely helper type that turns your instance into a compile-time readonly instance!

({...}) as never as ReadonlyKysely

db.selectFrom('person').selectAll() // no problem.<br>db.selectNoFrom(sql`now()`.as('now')) // no problem.

db.deleteFrom('person') // compilation error + deprecation!<br>db.insertInto('person').values({...}) // compilation error + deprecation!<br>db.mergeInto('person')... // compilation error + deprecation!<br>db.updateTable('person').set('first_name', 'Timmy') // compilation error + deprecation!<br>sql`...`.execute(db) // compilation error!<br>// etc. etc.">import { Kysely } from 'kysely'<br>import type { ReadonlyKysely } from 'kysely/readonly'

export const db = new KyselyDatabase>({...}) as never as ReadonlyKyselyDatabase>

db.selectFrom('person').selectAll() // no problem.<br>db.selectNoFrom(sql`now()`.as('now')) // no problem.

db.deleteFrom('person') // compilation error + deprecation!<br>db.insertInto('person').values({...}) // compilation error + deprecation!<br>db.mergeInto('person')... // compilation error + deprecation!<br>db.updateTable('person').set('first_name', 'Timmy') // compilation error + deprecation!<br>sql`...`.execute(db) // compilation error!<br>// etc. etc.

We got a brand new PGlite dialect. With it comes a new supportsMultipleConnections adapter flag that uses a new centralized connection mutex when false - should help simplify all SQLite dialects out here!

({<br>// ...<br>dialect: new PGliteDialect({<br>pglite: new PGlite(),<br>}),<br>// ...<br>})">import { PGlite } from '@electric-sql/pglite'<br>import { Kysely, PGliteDialect } from 'kysely'

const db = new KyselyDB>({<br>// ...<br>dialect: new PGliteDialect({<br>pglite: new PGlite(),<br>}),<br>// ...<br>})

We got $narrowType supporting nested narrowing and discriminated unions!

()<br>// output type narrowed to:<br>//<br>// {<br>// discriminatedUnionProfile: {<br>// auth: { type: 'token'; token: string }<br>// tags: string[]<br>// }<br>// }[]<br>.execute()">db.selectFrom('person_metadata')<br>.select(['discriminatedUnionProfile'])<br>// output type inferred as:<br>//<br>// {<br>// discriminatedUnionProfile: {<br>// auth:<br>// | { type: 'token'; token: string }<br>// | { type: 'session'; session_id: string }<br>// tags: string[]<br>// }<br>// }[]<br>.$narrowType{ discriminatedUnionProfile: { auth: { type: 'token' } } }>()<br>// output type narrowed to:<br>//<br>// {<br>// discriminatedUnionProfile: {<br>// auth: { type: 'token'; token: string }<br>// tags: string[]<br>// }<br>// }[]<br>.execute()

We got web standards driven query cancellation support. Pass an abort signal to execute* methods and similar. Pick between different inflight query abort strategies - ignore the query, cancel it on the database side or even kill the session on the database side.

({<br>dialect: new PostgresDialect({<br>// ...<br>controlClient: Client, // optional, for out-of-pool connections for database side query aborts.<br>//...

person type error compilation kysely deprecation

Related Articles