Hello! On Friday 10 April 2009 16:23:43 D. Richard Hipp wrote: > On Apr 10, 2009, at 5:58 AM, Alexey Pechnikov wrote: > > Note: TCL interface binds all as text values > > False. The following TCL script is proof by counter-example: > > package require sqlite3 > sqlite3 db :memory: > set x [expr {1+2}] > db eval { > CREATE TABLE t1(x); > INSERT INTO t1 VALUES($x); > } > puts [db one {SELECT typeof(x) FROM t1}]
But there is "constraint failed" error: package require sqlite3 sqlite3 db :memory: set x 1 db eval { CREATE TABLE t1(x integer check(typeof(x)='integer')); INSERT INTO t1 VALUES($x); } puts [db one {SELECT typeof(x) FROM t1}] TCL interface does use tcl variable type instead of database field type. It's not good because typeof(x) will be 'integer' here: package require sqlite3 sqlite3 db :memory: set x 1 db eval { CREATE TABLE t1(x integer); INSERT INTO t1 VALUES($x); } puts [db one {SELECT typeof(x) FROM t1}] So value of variable will be inserted as integer but typeof() function in constraint does return type 'text'. I think type conversion must be _before_ constraints checks. Best regards, Alexey Pechnikov. http://pechnikov.tel/ _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users