Skip Menu |

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 25100
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: TIMB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: Can't bind_param($idx, $value) if $idx is string that contains a number - PATCH
The problem is fixed in the first hunk of the attached patch. The rest are changes to improve testing in general, and especially to improve testing via DBD::Gofer.
Subject: DBD-SQLite-1.13.gofer1.patch
Only in DBD-SQLite-1.13.gofer1: Makefile.old diff -ru DBD-SQLite-1.13/dbdimp.c DBD-SQLite-1.13.gofer1/dbdimp.c --- DBD-SQLite-1.13/dbdimp.c 2006-09-08 05:50:50.000000000 +0100 +++ DBD-SQLite-1.13.gofer1/dbdimp.c 2007-02-23 15:36:26.000000000 +0000 @@ -441,13 +441,14 @@ { int pos; if (!SvIOK(param)) { - int len; + STRLEN len; char *paramstring; paramstring = SvPV(param, len); if( paramstring[len] == 0 && strlen(paramstring) == len) { pos = sqlite3_bind_parameter_index(imp_sth->stmt, paramstring); - if (pos==0) + if (pos==0 && (pos=(int)strtol(paramstring, (char **)NULL, 10)) == 0) { croak("Unknown named parameter"); + } pos = 2 * (pos - 1); } else { diff -ru DBD-SQLite-1.13/t/03insert.t DBD-SQLite-1.13.gofer1/t/03insert.t --- DBD-SQLite-1.13/t/03insert.t 2006-09-08 04:11:35.000000000 +0100 +++ DBD-SQLite-1.13.gofer1/t/03insert.t 2007-02-23 16:17:43.000000000 +0000 @@ -1,20 +1,25 @@ use Test; use DBI; -BEGIN { plan tests => 10 } +BEGIN { plan tests => 11 } my $dbh = DBI->connect("dbi:SQLite:dbname=foo", "", ""); ok($dbh); -my $sth = $dbh->prepare("INSERT INTO f VALUES (?, ?, ?)"); +ok($dbh->do("delete from f")); +my $sth = $dbh->prepare("INSERT INTO f VALUES (?, ?, ?)", { go_last_insert_id_args => [undef, undef, undef, undef] }); ok($sth); ok(my $rows = $sth->execute("Fred", "Bloggs", "fred\@bloggs.com")); ok($rows == 1); -ok($dbh->func('last_insert_rowid')); + +ok($sth->execute("test", "test", "1"), 1); +ok($sth->execute("test", "test", "2"), 1); +ok($sth->execute("test", "test", "3"), 1); + my $unless_min_dbi = $DBI::VERSION < 1.43 ? 'last_insert_id requires DBI v1.43' : ''; -skip($unless_min_dbi, $dbh->last_insert_id(undef, undef, undef, undef) ); -ok($sth->execute("test", "test", "1")); -ok($sth->execute("test", "test", "2")); -ok($sth->execute("test", "test", "3")); -ok($dbh->do("delete from f where f1='test'") == 3); +skip($unless_min_dbi, $dbh->last_insert_id(undef, undef, undef, undef), 4 ); + +ok($dbh->func('last_insert_rowid'), 4, 'last_insert_rowid should be 4'); + +ok($dbh->do("delete from f where f1='test'"), 3); $sth->finish; undef $sth; $dbh->disconnect; diff -ru DBD-SQLite-1.13/t/04select.t DBD-SQLite-1.13.gofer1/t/04select.t --- DBD-SQLite-1.13/t/04select.t 2006-09-08 04:12:00.000000000 +0100 +++ DBD-SQLite-1.13.gofer1/t/04select.t 2007-02-23 16:16:34.000000000 +0000 @@ -30,7 +30,7 @@ while ($row = $sth->fetch) { $num_rows++; } -ok($num_rows == 1, 1, "Check num_rows ($num_rows) == 1"); +ok($num_rows, 1, "Check num_rows ($num_rows) == 1"); $sth->finish; $dbh->do("delete from f where f1='test'"); $sth = $dbh->prepare("INSERT INTO f (f1, f2, f3) VALUES (?, ?, ?)"); diff -ru DBD-SQLite-1.13/t/11unicode.t DBD-SQLite-1.13.gofer1/t/11unicode.t --- DBD-SQLite-1.13/t/11unicode.t 2005-08-05 18:15:09.000000000 +0100 +++ DBD-SQLite-1.13.gofer1/t/11unicode.t 2007-02-23 16:20:41.000000000 +0000 @@ -106,7 +106,17 @@ # Start over but now activate Unicode support. -$dbh->{unicode} = 1; +if ($ENV{DBI_AUTOPROXY}) { + # for testing DBD::Gofer we have to create a new dbh with unicode enabled + # because we can't change the attribute for an existing dbh + $dbh = DBI->connect($test_dsn, $test_user, $test_password, { + RaiseError => 1, + unicode => 1, + }) +} +else { + $dbh->{unicode} = 1; +} ($textback, $bytesback) = database_roundtrip($utfstring, $bytestring); diff -ru DBD-SQLite-1.13/t/lib.pl DBD-SQLite-1.13.gofer1/t/lib.pl --- DBD-SQLite-1.13/t/lib.pl 2006-09-08 00:24:27.000000000 +0100 +++ DBD-SQLite-1.13.gofer1/t/lib.pl 2007-02-23 16:24:36.000000000 +0000 @@ -12,6 +12,8 @@ use vars qw($mdriver $dbdriver $childPid $test_dsn $test_user $test_password $haveFileSpec); +$| = 1; # flush stdout asap to keep in sync with stderr + # # Driver names; EDIT THIS! @@ -171,7 +173,8 @@ print "ok $::numTests ". (defined($error) ? "$error\n" : "\n"); return 1; } else { - print("not ok $::numTests - " . + my ($pack, $file, $line) = caller(); + print("not ok $::numTests at line $line - " . (defined($error) ? "$error\n" : "\n")); print("FAILED Test $::numTests - " . (defined($error) ? "$error\n" : "\n"));
Fixed in svn (but thanks for the test patch).