-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix "Cannot convert undefined to a BigInt" #8
Conversation
src/index.ts
Outdated
@@ -107,7 +107,7 @@ class D1Connection implements DatabaseConnection { | |||
} | |||
|
|||
return { | |||
insertId: results.lastRowId !== null ? BigInt(results.lastRowId) : undefined, | |||
insertId: !results.lastRowId ? undefined : BigInt(results.lastRowId), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this documented in cloudflare's docs anywhere, do you have a link to it? If so, lets insert a comment?
I'm also concerned about other zero values here, hence the explicit check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not documented sadly, but I get a lot of undefined
s. I added a new commit that returns the original variable so things like 0 and NaN get returned as is.
🤔 Now I'm wondering if there is a difference between those two and we should aim to return the correct types Edit: yep looks like this generates type errors, check the build 👍 |
Is it ok like this? |
These changes all make sense to me now, thank you for the contribution! |
* 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]>
example
project.Description
I fixed the following exception when executing queries: