node-sqlite3 icon indicating copy to clipboard operation
node-sqlite3 copied to clipboard

Cast boolean values (0,1) to real boolean types in JS

Open MartinMuzatko opened this issue 8 years ago • 3 comments

Hello!

In SQLite, thare no real boolean values.

SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true). https://www.sqlite.org/datatype3.html

To allow better comparison and strict equals in javascript, shouldn't select statements return 0 as false and 1 as true? Or should the DB work as single source of truth.

What are your thoughts?

MartinMuzatko avatar Feb 12 '18 13:02 MartinMuzatko

So far i know almost all Relational database stores boolean as numbers but SQLite does not have any specific datatype for this like Microsoft SQL Server has bit datatype which store 1 and 0 only. you can simply use INTEGER and handle the logic in you code.

Rahulkr2 avatar Feb 13 '18 17:02 Rahulkr2

Any update on this? I think it should be handled in the driver.

jbis9051 avatar Dec 23 '20 17:12 jbis9051

I think this is extremely unlikely to ever happen - it's such a big breaking change that the switchover would be rough and I think everyone who uses SQLite knows of its quirks 🙂 I'm going to close this for now

daniellockyer avatar Sep 08 '22 21:09 daniellockyer