Skip Menu |
 

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

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

People
Owner: Nobody in particular
Requestors: kenneth.kroenlein [...] nist.gov
Cc:
AdminCc:

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



Subject: primary_key_info fails to return names for named primary keys
Date: Fri, 9 May 2014 13:00:47 -0600
To: <bug-DBD-SQLite [...] rt.cpan.org>
From: Kenneth Kroenlein <kenneth.kroenlein [...] nist.gov>
Download (untitled) / with headers
text/plain 1.2k
Feature request: For DBD::SQLite, v. 1.40 and v.142, all calls to primary_key_info return the name of the primary key to be 'PRIMARY KEY', despite SQLite supporting named constraints. Modifying the lines that read (start 453 in v.1.40): my $key_seq = 0; foreach my $pk_field (@pk) { push @pk_info, { TABLE_SCHEM => $dbname, TABLE_NAME => $tbname, COLUMN_NAME => $pk_field, KEY_SEQ => ++$key_seq, PK_NAME => 'PRIMARY KEY', }; } to my $key_name = $row->{sql} =~ /\bCONSTRAINT\s+(\S+|"[^"]+")\s+PRIMARY\s+KEY\s*\(/i ? $1 : 'PRIMARY KEY'; my $key_seq = 0; foreach my $pk_field (@pk) { push @pk_info, { TABLE_SCHEM => $dbname, TABLE_NAME => $tbname, COLUMN_NAME => $pk_field, KEY_SEQ => ++$key_seq, PK_NAME => $key_name, }; } should correct the oversight and should be quite robust (barring some fairly pathological conditions). Thanks, Ken
Download (untitled) / with headers
text/plain 1.4k
Thanks. Applied in the master: https://github.com/DBD-SQLite/DBD-SQLite/commit/354d07f61f0529d2a26aaed106a5f3651080ff54 On Sat May 10 04:01:14 2014, kenneth.kroenlein@nist.gov wrote: Show quoted text
> Feature request: > > For DBD::SQLite, v. 1.40 and v.142, all calls to primary_key_info return > the name of the primary key to be 'PRIMARY KEY', despite SQLite > supporting named constraints. Modifying the lines that read (start 453 > in v.1.40): > > my $key_seq = 0; > foreach my $pk_field (@pk) { > push @pk_info, { > TABLE_SCHEM => $dbname, > TABLE_NAME => $tbname, > COLUMN_NAME => $pk_field, > KEY_SEQ => ++$key_seq, > PK_NAME => 'PRIMARY KEY', > }; > } > > to > > my $key_name = $row->{sql} =~ > /\bCONSTRAINT\s+(\S+|"[^"]+")\s+PRIMARY\s+KEY\s*\(/i ? $1 : 'PRIMARY KEY'; > my $key_seq = 0; > foreach my $pk_field (@pk) { > push @pk_info, { > TABLE_SCHEM => $dbname, > TABLE_NAME => $tbname, > COLUMN_NAME => $pk_field, > KEY_SEQ => ++$key_seq, > PK_NAME => $key_name, > }; > } > > should correct the oversight and should be quite robust (barring some > fairly pathological conditions). > > Thanks, > Ken >
Closed as 1.44 was released. Thanks.


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.