kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
9.81k stars 249 forks source link

getting started documentation errors with MssqlDialect #1044

Closed zivni closed 2 weeks ago

zivni commented 2 weeks ago

in the getting started with MssqlDialect, the example is:

export async function createPerson(person: NewPerson) {
  const compiledQuery = db.insertInto('person').values(person).compile()

  compiledQuery.sql += '; select scope_identity() as id' // Error is on this line

  const {
    rows: [{ id }],
  } = await db.executeQuery<Pick<Person, 'id'>>(compiledQuery)

  return await findPersonById(id)
}

getting the error: Cannot assign to 'sql' because it is a read-only property. this is due the the fact that the sql property in src/query-compiler/compiled-query.ts as readonly sql: string