Ok.  This behaviour is documented here:  

https://www.sqlite.org/lang_expr.html#booleanexpr


---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of Keith Medcalf
>Sent: Saturday, 1 December, 2018 12:45
>To: SQLite mailing list
>Subject: [sqlite] is True (was: geopoly_contains_point(P, X, Y) doc
>is overly modest)
>
>
>On Saturday, 1 December, 2018 12:23, Richard Hipp <d...@sqlite.org>
>wrote"
>
>>On 12/1/18, Keith Medcalf <kmedc...@dessus.com> wrote:
>
>>>>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 expect
>>> (assuming that one is a programmer is a language that behaves
>>> as the underlying hardware (CPU) behaves).
>
>> Yeah, but Mr. Damon is probably right that the documentation should
>> be more precise.  So I have now updated it.
>
>I concur.
>
>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.
>
>
>
>
>
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to