Keith Medcalf
2018-12-01 19:45:00 UTC
Maybe it should say 'Non-Zero' or 'Greater than Zero' rather than
true, since true, as a symbol, as a special value.
Yes and no, True and False is SQLite work as one would expecttrue, since true, as a symbol, as a special value.
(assuming that one is a programmer is a language that behaves
as the underlying hardware (CPU) behaves).
be more precise. So I have now updated it.
There is however a slight anomaly with how the "is True" test works that has to do with how type affinities work such that "is True" does not work entirely as one would expect from a machine perspective. Presently the LHS of an "is True" is not NUMERIC it is converted to NUMERIC before the "is True" expression is evaluated, rather than "is True" being a test for any bits being 1 the LHS.
This means that ('' is true) evaluates to 0, which is expected, since there are no bits set in the value on the LHS (it also by happenstance converts to 0 in numeric affinity). However (select 'a' is true) evaluates to 0. This is incorrect because there are bits set in the value on the LHS. However if the LHS can be cast to numeric the test works as expected:
sqlite> select '' is true;
0
sqlite> select 'a' is true;
0
sqlite> select '1' is true;
1
sqlite> select '2' is true;
1
sqlite> select '.1' is true;
1
sqlite> select '-1' is true;
1
sqlite> select '-0.1' is true;
1
sqlite> select '0' is true;
0
sqlite> select '0.0' is true;
0
sqlite> select '0.1' is true;
1
I don't recall if this is documented anywhere but one should expect (at least I would expect) that ('a' is true) should evaluate as 1, not 0, since there are bits set in the value on the LHS.