Closed pergunt closed 1 year ago
Hey 👋
Outside of Kysely class instantiation, the API is dialect agnostic by design.
Reason behind undefined
:
You can add a !
assertion as follows:
return db.selectFrom('test_users')
.selectAll()
.where('id', '=', result.insertId!)
.executeTakeFirst()
I use
MySQL
dialect. After I insert a new record and want to get this record by the getter from theInsertResult
constructor, I seeTypeScript
error**Type 'undefined' is not assignable to type 'OperandValueExpressionOrList<From<DB, "test_users">, "test_users", "id">
**So I have to cast this:
My question is: "is it a bug that current
InsertResult
constructor looks like this:Why
insertID
can be undefined if MySQL always returns it afterinsert
operations is done?