Skip Menu |

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

Report information
The Basics
Id: 5457
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: 0.31
Fixed in: (no value)



Subject: primary_key bug
Just a small fix and associated test for a small edge case. old version would handle create table meta5 (f1 integer PRIMARY KEY ) but not create table meta5 ( f1 integer PRIMARY KEY )
diff -ur DBD-SQLite-0.31/lib/DBD/SQLite.pm new/lib/DBD/SQLite.pm --- DBD-SQLite-0.31/lib/DBD/SQLite.pm 2004-02-15 06:13:51.000000000 +1100 +++ new/lib/DBD/SQLite.pm 2004-02-26 17:10:17.000000000 +1100 @@ -191,7 +191,7 @@ my @pk = split /\s*,\s*/, $2 || ''; unless (@pk) { my $prefix = $1; - $prefix =~ s/.*create\s+table\s+.*?\(//i; + $prefix =~ s/.*create\s+table\s+.*?\(\s*//i; $prefix = (split /\s*,\s*/, $prefix)[-1]; @pk = (split /\s+/, $prefix)[0]; # take first word as name } Only in new: output diff -ur DBD-SQLite-0.31/t/60metadata.t new/t/60metadata.t --- DBD-SQLite-0.31/t/60metadata.t 2003-08-11 08:33:34.000000000 +1000 +++ new/t/60metadata.t 2004-02-26 17:25:50.000000000 +1100 @@ -1,10 +1,10 @@ use Test; -BEGIN { plan tests => 24 } +BEGIN { plan tests => 26 } use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=foo", "", "", { }); ok($dbh); $dbh->{PrintError} = 0; -$dbh->do("drop table meta$_") for 1..4; +$dbh->do("drop table meta$_") for 1..5; $dbh->{PrintError} = 1; ok $dbh->do("create table meta1 (f1 varchar(2) PRIMARY KEY, f2 char(1))"); ok $dbh->do("create table meta2 (f1 varchar(2), f2 char(1), PRIMARY KEY (f1))"); @@ -43,4 +43,8 @@ print "# Types: @$types\n"; print "# Names: @$names\n"; ok($types->[0] eq 'varchar(2)'); -ok($types->[1] eq 'char(1)'); \ No newline at end of file +ok($types->[1] eq 'char(1)'); + +ok $dbh->do("create table meta5 ( f1 integer PRIMARY KEY )"); +@pk = $dbh->primary_key(undef, undef, 'meta5'); +ok($pk[0] eq 'f1');