SQLite Forum

Bug when converting string to boolean?
SQLite3 does not have a boolean type.  It has NULL, TEXT, INTEGER, and REAL.

For the purpose of comparison (greater than, less than, equals, not equals) or assignment, then TRUE is the INTEGER 1 and FALSE is the INTEGER 0.

For the purpose of ISing (a test of being), IS TRUE means "not 0 and not null" and IS FALSE means "is 0 and not null".

TRUE and FALSE are "magical words" unless there is a column in one of the tables in the query named TRUE or FALSE, in which case it is that column and not the magical value.

Something which evaluates to a non-zero and non-null numeric value IS TRUE, and something which evaluates to a zero value IS FALSE.  If you want to know if something IS TRUE or IS FALSE then it must be converted to numeric first -- you have no choice in the matter.  However testing whether something equals 1 does not require any conversions whatsoever unless the affinity conversion rules apply.  And constants do not have affinity.  And a text constant is *never* equal to an integer constant.