Skip Menu |
 

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

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

People
Owner: Nobody in particular
Requestors: david_dick [...] iprimus.com.au
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.07
Fixed in: (no value)

Attachments


Subject: Version 3 datatype oddness with proposed patch and testcases
Download (untitled) / with headers
text/plain 229b
it is now possible in DBD::SQLite to CREATE TABLE foo (id); INSERT INTO foo VALUES("5"); DELETE FROM foo WHERE foo = 5; which fails to delete the necessary row. Associated testcase to prove this + proposed patch are attached.
diff -Naur DBD-SQLite-1.07/dbdimp.c working/dbdimp.c --- DBD-SQLite-1.07/dbdimp.c 2004-10-05 06:02:21.000000000 +1000 +++ working/dbdimp.c 2004-10-28 13:08:21.000000000 +1000 @@ -345,10 +345,6 @@ char * data = SvPV(value, len); retval = sqlite3_bind_blob(imp_sth->stmt, i+1, data, len, SQLITE_TRANSIENT); } - else if (SvNIOK(value)) { - /* bind ordinary numbers as numbers - otherwise we might sort wrong */ - retval = sqlite3_bind_double(imp_sth->stmt, i+1, SvNV(value)); - } else { STRLEN len; char * data = SvPV(value, len); diff -Naur DBD-SQLite-1.07/t/04select.t working/t/04select.t --- DBD-SQLite-1.07/t/04select.t 2003-08-12 07:51:14.000000000 +1000 +++ working/t/04select.t 2004-10-28 14:19:18.000000000 +1000 @@ -1,5 +1,5 @@ use Test; -BEGIN { plan tests => 7 } +BEGIN { plan tests => 21 } use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=foo", "", "", { RaiseError => 1 }); ok($dbh); @@ -14,4 +14,39 @@ ok($rows); ok($sth->fetch); $sth->finish; +$sth = $dbh->prepare("INSERT INTO f (f1, f2, f3) VALUES (?, ?, ?)"); +ok($sth); +ok($sth->execute("test", "test", 1)); +$sth->finish; +$sth = $dbh->prepare("DELETE FROM f WHERE f3 = ?"); +ok($sth); +ok($sth->execute("1")); +$sth->finish; +$sth = $dbh->prepare("SELECT * FROM f"); +ok($sth); +ok($sth->execute()); +my $num_rows = 0; +while ($row = $sth->fetch) { + $num_rows += 1; +} +ok($num_rows == 1); +$sth->finish; +$dbh->do("delete from f where f1='test'"); +$sth = $dbh->prepare("INSERT INTO f (f1, f2, f3) VALUES (?, ?, ?)"); +ok($sth); +ok($sth->execute("test", "test", 1.05)); +$sth = $dbh->prepare("DELETE FROM f WHERE f3 = ?"); +ok($sth); +ok($sth->execute("1.05")); +$sth->finish; +$sth = $dbh->prepare("SELECT * FROM f"); +ok($sth); +ok($sth->execute()); +my $num_rows = 0; +while ($row = $sth->fetch) { + $num_rows += 1; +} +ok($num_rows == 1); +$sth->finish; +$dbh->do("delete from f where f1='test'"); $dbh->disconnect;


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.