You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue #907 was caused by a problem I come across at runtime occasionally: inserting boolean values into SQLite raises a TypeError because a boolean is not a number, string, bigint, buffer, or null. I understand that this is a design decision to keep the better-sqlite3 interface symmetrical with the SQLite interface, which seems reasonable to me.
However, would you consider a PR that added an option (probably here) to automatically cast booleans to their SQLite equivalent (0 or 1)? SQLite itself will convert the keywordstrue and false to their integer equivalents, which is in keeping with the loose typing philosophy.
The text was updated successfully, but these errors were encountered:
This certainly was a stumbling block for me when I first started using better-sqlite3 (followed by my surprise that SQLite had no native support for boolean or date types!).
I think @JoshuaWise 's comment still holds, though: if we automatically converted boolean bound values, it would be potentially (very) surprising when you get back a 0|1 from the same row. I don't see a straightforward heuristic to supporting this.
if we automatically converted boolean bound values, it would be potentially (very) surprising when you get back a 0|1 from the same row. I don't see a straightforward heuristic to supporting this.
You could say the same thing about SQLite itself, which does exactly this.
Issue #907 was caused by a problem I come across at runtime occasionally: inserting boolean values into SQLite raises a TypeError because a boolean is not a number, string, bigint, buffer, or null. I understand that this is a design decision to keep the
better-sqlite3
interface symmetrical with the SQLite interface, which seems reasonable to me.However, would you consider a PR that added an option (probably here) to automatically cast booleans to their SQLite equivalent (
0
or1
)? SQLite itself will convert the keywordstrue
andfalse
to their integer equivalents, which is in keeping with the loose typing philosophy.The text was updated successfully, but these errors were encountered: