[DBD-SQLite] problem with string values that look like a number

Michael Lackhoff michael at lackhoff.de
Wed Apr 8 11:54:06 GMT 2009


I have a problem with 1.20 that appeared somewhere between 1.19_01 and 1.20.

This demonstrates it:
my $dbh = DBI->connect("dbi:SQLite:dbname=mydb","","");
$dbh->do(q{
CREATE TABLE mytable (
    nr CHAR (2) NOT NULL PRIMARY KEY,
    name VARCHAR
)
});
my $sql = q{select nr, name from mytable where nr = ?};
my $nr = '01';
my $sth = $dbh->prepare($sql);
$sth->execute($nr); # 0 rows, wrong

whereas this works:
my $sql = q{select nr, name from kassentypen where nr = '01'};
my $sth = $dbh->prepare($sql);
$sth->execute(); # 1 row, as expected

I am not sure if this is a bug or a feature because of this change log
entry for 1.19_09:
    - Resolved #29058: don't quote a bind param (as a text) if it
      looks like a number (ISHIGAKI)

That is why I ask first before filing a bug report. If it is not
possible to use the schema to decide if it is a number or a string,
perhaps at least numbers with leading zeros should be quoted?

-Michael






More information about the DBD-SQLite mailing list