Subject: | foreign_key_info () does not honor FetchHashKeyName attribute |
--8<--- test.pl
use strict;
use warnings;
use DBI;
use Data::Peek;
my $dbh = DBI->connect ($ENV{DBI_DSN}, undef, undef, {
AutoCommit => 0,
ChopBlanks => 1,
FetchHashKeyName => "NAME_lc",
PrintError => 1,
RaiseError => 1,
ShowErrorStatement => 1,
# dbd_verbose => 9,
}) or die $DBI::errstr;
my $sch = "public";
my $tbl = "test$$";
$dbh->do ("create table B$tbl (c_test integer primary key, test varchar
(4))");
$dbh->do ("insert into B$tbl values (1, 'test')");
$dbh->do ("create table $tbl (c_test integer)");
$dbh->do ("alter table $tbl add constraint ".
"L$tbl foreign key (c_test) references ".
"B$tbl (c_test)");
$dbh->do ("insert into $tbl values (1)");
my $stl = $dbh->foreign_key_info (
undef, undef, undef,
undef, $sch, $tbl) or die;
$stl->execute;
DDumper ($stl->fetchrow_hashref);
my $sth = $dbh->prepare ("select * from $sch.$tbl");
$sth->execute;
DDumper ($sth->fetchrow_hashref);
$dbh->do ("drop table $tbl");
$dbh->do ("drop table B$tbl");
-->8---
$ perl test.pl
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"btest25869_pkey" for table "btest25869"
$VAR1 = {
DEFERABILITY => '7',
DELETE_RULE => '3',
FK_COLUMN_NAME => 'c_test',
FK_DATA_TYPE => 'int4',
FK_NAME => 'ltest25869',
FK_TABLE_CAT => undef,
FK_TABLE_NAME => 'test25869',
FK_TABLE_SCHEM => 'public',
ORDINAL_POSITION => 1,
UK_COLUMN_NAME => 'c_test',
UK_DATA_TYPE => 'int4',
UK_NAME => 'btest25869_pkey',
UK_TABLE_CAT => undef,
UK_TABLE_NAME => 'btest25869',
UK_TABLE_SCHEM => 'public',
UNIQUE_OR_PRIMARY => 'PRIMARY',
UPDATE_RULE => '3'
};
$VAR1 = {
c_test => '1'
};
Issuing rollback() for database handle being DESTROY'd without explicit
disconnect().
All the keys in the return hash from foreign_key_info () should be
lower case!