How does SQLite handle bool values?
SQLite doesn’t have a native bool type. You can create a column called that but that’s just SQLite lying to you. You can fix that lie by making the table strict.
-- Some preparation:
CREATE TABLE `foo` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`fakebool` INT,
`value` TEXT
);
insert into foo(fakebool, value) VALUES (0, 'zero');
insert into foo(fakebool, value) VALUES (1, 'one yep');
insert into foo(fakebool, value) VALUES (NULL, 'is null');
-- And here are some samples to demonstrate SQLite's behavior
select * from foo;
-- 1|0|zero
-- 2|1|one yep
-- 3||is null
select * from foo where fakebool;
-- 2|1|one yep
select * from foo where not fakebool;
-- 1|0|zero
select * from foo where fakebool = TRUE;
-- 2|1|one yep
select * from foo where fakebool = FALSE;
-- 1|0|zero