Skip Menu |

This queue is for tickets about the Class-DBI-Pg CPAN distribution.

Report information
The Basics
Id: 28550
Status: new
Priority: 0/
Queue: Class-DBI-Pg

People
Owner: Nobody in particular
Requestors: cushing [...] bitlathe.com
Cc:
AdminCc:

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



Subject: Primary Key sequence detection fail in edge case
I've found an edge case where Class::DBI::Pg's primary key sequence detection falls down. When a SERIAL-valued primary key is added to a table after any other column with a default value, the current method fails because query that returns the default values doesn't list the primary key first (at least in pg 8.1.3). The attached patch refines the query to only return the default values associated with any of the primary key columns. It still only takes the first value, so multi-column, SERIAL-valued primary keys still fail, but Class::DBI can't handle them automatically anyway (I don't think...). I think this should also fix bug #12154.
Subject: Class_DBI_Pg_0.09_Primary_key_sequence.patch
--- Pg.pm.orig 2007-07-29 22:05:47.000000000 -0500 +++ Pg.pm 2007-07-29 22:22:34.000000000 -0500 @@ -52,8 +52,10 @@ SELECT adsrc FROM ${catalog}pg_attrdef WHERE adrelid=(SELECT oid FROM ${catalog}pg_class WHERE relname=?) +AND adnum IN (?) SQL - $sth->execute($table); + my $prinumstr = join ',',keys %prinum; + $sth->execute($table,$prinumstr); my ($nextval_str) = $sth->fetchrow_array; $sth->finish;