kysely
0.29.9 · 12 Nov 2026MIT32M / weekRepositoryHomepagenpmAtom feed
0.29.9 is the newest release of 0.28.x.
In short
1 new1 fixed
Security
3 advisories affect 0.28.2; 0.28.17 fixes them
- HighKysely: JSON-path traversal injection via unsanitized path-leg metacharacters in `JSONPathBuilder.key()` / `.at()`GHSA-pv5w-4p9q-p3v2 · 11 May 2026Fixed in 0.28.17
- HighKysely has a MySQL SQL Injection via Insufficient Backslash Escaping in `sql.lit(string)` usage or similar methods that append string literal values into the compiled SQL stringsGHSA-8cpq-38p9-67gx · 20 Mar 2026Fixed in 0.28.14
- HighSQL Injection via unsanitized JSON path keys when ignoring/silencing compilation errors or using `Kysely<any>`.GHSA-wmrf-hv6w-mr66 · 18 Mar 2026Fixed in 0.28.12
Release note
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
tabletoDynamicModulefor dynamic table references
Bugfixes
SQLite
SQLite's introspector is printing deprecation errors for
orderBy(array).
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.