Quick question/potential feature request about the following:
const result = await db
.deleteFrom("Log")
.where("expiresAt", "<=", date)
.executeTakeFirst();
const count = result.numDeletedRows ? Number(result.numDeletedRows) : 0;
Running the example above, result is always an object with type DeleteResult, but if 0 rows are deleted, result.numDeletedRows returns undefined and result is empty, but the type of numDeletedRows according to typescript is always bigint. If 1 or more rows are deleted, result.numDeletedRows returns an accurate count as type bigint as expected.
I am not sure if this is the intended behavior, a bug on my end, if I am overlooking something, or if there is something I can change, but as a suggestion I feel that if the undefined return value behavior is correct, then the return type for result.numDeletedRows should represent that correctly as bigint | undefined, otherwise if it is not intended behavior, return 0 if 0 rows are deleted.
I am using the planetscale dialect for reference, and generating types using kysely-codegen
You should open this issue in kysely-planetscale repo. Their implementation is wrong. kysely-planetscale is a third party dialect and we have no control over it.
👋
Quick question/potential feature request about the following:
Running the example above,
result
is always an object with typeDeleteResult
, but if 0 rows are deleted,result.numDeletedRows
returnsundefined
andresult
is empty, but the type ofnumDeletedRows
according to typescript is alwaysbigint
. If 1 or more rows are deleted,result.numDeletedRows
returns an accurate count as typebigint
as expected.I am not sure if this is the intended behavior, a bug on my end, if I am overlooking something, or if there is something I can change, but as a suggestion I feel that if the
undefined
return value behavior is correct, then the return type forresult.numDeletedRows
should represent that correctly asbigint | undefined
, otherwise if it is not intended behavior, return 0 if 0 rows are deleted.I am using the planetscale dialect for reference, and generating types using
kysely-codegen
Thanks!