Skip to content

Commit

Permalink
Fix "Cannot convert undefined to a BigInt" (#8)
Browse files Browse the repository at this point in the history
* Fix "Cannot convert undefined to a BigInt"

* Return original variable if conversion to BigInt is not possible

* Only return `undefined` on `null` or `undefined`

Co-authored-by: Aiden <[email protected]>
  • Loading branch information
KernelFreeze and aidenwallis authored Nov 25, 2022
1 parent 668c7a8 commit cbd3c97
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class D1Connection implements DatabaseConnection {
}

return {
insertId: results.lastRowId !== null ? BigInt(results.lastRowId) : undefined,
insertId: results.lastRowId === undefined || results.lastRowId === null ? undefined : BigInt(results.lastRowId),
rows: (results?.results as O[]) || [],
numUpdatedOrDeletedRows: results.changes > 0 ? BigInt(results.changes) : undefined,
};
Expand Down

0 comments on commit cbd3c97

Please sign in to comment.