As everyone else has pointed out, SQLite does not support a specific boolean storage type, and the OP specifically acknowledges this fact. However, this is completely independent of whether SQLite supports boolean literals and comprehensions.
For anyone wondering, the answer is YES, since SQLite 3.23 you can do boolean comprehensions with the boolean literals TRUE
and FALSE
, and it will work how you expect.
For example, you can do:
SELECT * FROM blah WHERE some_column IS FALSE;
SELECT * FROM blah WHERE some_column IS TRUE;
and it will work how you expect if you are using 0
for false and 1
for true.
From my testing, here is how SQLite matches various values:
- Any non-zero NUMERIC, INTEGER, or REAL:
IS TRUE
- Any zero NUMERIC, INTEGER, or REAL:
IS FALSE
- A null value:
IS NULL
. Does not match IS TRUE
or IS FALSE
.
- Any TEXT that does not parse to a numeric value:
IS FALSE
. Even values like "t", "TRUE", "true", "True" still match IS FALSE
- TEXT that looks like a number (eg "0", "1", "5"): Behaves like NUMERIC, listed above.
- BLOB: Untested.