-
Notifications
You must be signed in to change notification settings - Fork 67
Add undefined
and boolean
to BindingSpec
type
#83
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
Conversation
Achtung: whether undefined counts as null depends on the API. In some of them (am on a mobile device so cannot readily verify which ones), undefined is used as a no-op to simplify certain binding cases. e.g. oo1.Stmt.bind() does not treat undefined like null. |
Oops. Let me put some more thought into this.
Well technically you can still pass if even if it is a no-op. |
// this works
db.prepare("INSERT INTO test VALUES (?, ?, ?)").bind([2, undefined, 1]).step()
// also works
db.prepare("INSERT INTO test VALUES (?, ?, ?)").bind(1, 1).bind(2, undefined).bind(3, 3).step();
// also seems to work
db.prepare("INSERT INTO test VALUES (?, 2, 3)").bind(undefined).step() From the docs:
|
@sgbeal I modified the pull request to not allow |
Note that the default value for unbound parameters is null, so in the above cases it will appear as if undefined translates to null, but it's not really doing so. In these cases, it's just coincidence. |
@sgbeal Yes I figured! That is why I excluded |
Historical note: the undefined==noop oddity was based on client-side experience with an earlier sqlite binding done for a different language (this particular binding being my 7th-ish). Though i currently cannot for the life of me find a concrete example where that was useful for me, it did have a genuine utility at the time it was conceived and implemented. If i can manage to remember specifically what that utility is i'll update the docs to explain it. |
i'm a poor judge of typescript but it looks fine to my layman's eyes. |
Even though these types will never be retrieved from SQLite, using them in a bind is perfectly valid.
undefined
will get translated toNULL
,boolean
to1
(true) or0
(false).