SQLite Forum

conversion of literal values, or lack thereof
Login

conversion of literal values, or lack thereof

(1) By Poor Yorick (pooryorick) on 2021-06-04 12:33:04 [link]

In the following example, the literal value <code>'1'</code> is not converted
to a numeric value in the first case, but in the second and third cases, it is:

<code><verbatim>
create table t1(c1 integer)
; insert into t1(c1) values (1)

;select 1 = '1'
, cast(1 as numeric) = '1'
, (select c1 from t1 where c1 = 1) = '1'
</verbatim></code>

Output:

<code><verbatim>
0 1 1
</verbatim></code>

Why not make that more consistent by converting in the first case as well?

(2) By Richard Hipp (drh) on 2021-06-04 14:26:36 in reply to 1

The suggestion makes sense.  Except the current behavior is very carefully
documented and tested and has been in use for many years.  We can't risk breaking
billions and billions of deployed applications for a small increase in
design consistency.