This script
#!/usr/bin/env tclsh
package require sqlite3
set x 1
sqlite3 db /tmp/foo
db eval {select (2 > :x) as foo} {
puts "foo was $foo"
}
run on an up-to-date Arch Linux system produces
foo was 0
obviously incorrect. There seems to be an issue with variable
substitution here. Changing the line in question to
db eval {select (2 > 1) as foo} {
and re-running produces
foo was 1
obviously correct.
The sqlite documentation on the tcl api says that variable
substitution can occur "in any position where it is legal to put a
string or number literal". There is no information in the
documentation about how to control this, so the api has to be deciding
for itself whether a string or numeric literal is appropriate and I
think it is getting it wrong here.
db eval {select (2 > cast (:x as integer)) as foo} {
works correctly.
db eval {select (2 > '1') as foo} {
produces
foo was 0
Looks like a bug to me, but perhaps I'm missing something. Comments?
/Don Allen
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users