0.17.0
Breaking changes
db.raw
has been replaced with the sql template tag. sql
is a free function that can be used with or without a Kysely
instance.
See the docs for detailed instructions. Here's how you'd replace the most common use cases of the old db.raw
:
import { sql } from 'kysely'
// old
db.raw('select first_name from person where id = ?', [id])
// new
sql`select first_name from person where id = ${id}`
import { sql } from 'kysely'
// old
db.raw('select ?? from person', ['first_name'])
// new
sql`select ${sql.ref('first_name')} from person`
import { sql } from 'kysely'
// old
const result = await db.raw('select first_name from person where id = ?', [id]).execute()
// new
const result = await sql`select first_name from person where id = ${id}`.execute(db)