On Mar 6, 2013, at 10:49 PM, Nico Williams <n...@cryptonector.com> wrote:

> Ah, your confusion comes from the fact that type conversion still
> happens when the INSERT gets around to making the record.  The CHECK
> constraint happens before the record is made.  See the vdbe that gets
> generated.

All good. Small sanity check though:


select 2 = cast( '2' as integer );
> 1

Ok… '2' is can be casted to 2… great...


select 2 = cast( 'a2' as integer );
> 0

Ok… 'a2' cannot really be casted to an integer… cool...


select 2 = cast( '2.1' as integer );
> 1

Hmmm….


select 2 = cast( '2abc' as integer );
> 1

Whaaaaat?!? Oh… "When casting a TEXT value to INTEGER, the longest possible 
prefix of the value that can be interpreted as an integer number is extracted 
from the TEXT value and the remainder ignored. "… ah… ok… weird…

So…

select cast( 'abc' as integer );
> 0

o k i d o k i . . .







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

Reply via email to