[svn:DBD-Pg] r12779 - in DBD-Pg/trunk: . t

[email protected]
Newsgroups gmane.comp.db.postgresql.dbdpg.cvs
Message-ID <[email protected]>
Author: turnstep
Date: Mon May 18 10:53:47 2009
New Revision: 12779

Modified:
   DBD-Pg/trunk/Changes
   DBD-Pg/trunk/Pg.pm
   DBD-Pg/trunk/t/03dbmethod.t

Log:
CPAN bug 46103: Make foreign_key_info respect FetchHashKeyName setting.


Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes	(original)
+++ DBD-Pg/trunk/Changes	Mon May 18 10:53:47 2009
@@ -1,5 +1,9 @@
 ('GSM' is Greg Sabino Mullane, greg-738XdyZ4GzZWk0Htik3J/[email protected])
 
+2.13.2
+
+  - Make foreign_key_info() respect FetchHashKeyName (CPAN bug #46103) [GSM]
+
 2.13.1 Released April 23, 2009 (subversion r12713)
 
   - Fix leak in pg_warn (CPAN bug #45163) [[email protected]]

Modified: DBD-Pg/trunk/Pg.pm
==============================================================================
--- DBD-Pg/trunk/Pg.pm	(original)
+++ DBD-Pg/trunk/Pg.pm	Mon May 18 10:53:47 2009
@@ -834,6 +834,10 @@
 
 		## PK: catalog, schema, table, FK: catalog, schema, table, attr
 
+		my $oldname = $dbh->{FetchHashKeyName};
+
+		local $dbh->{FetchHashKeyName} = 'NAME_lc';
+
 		## Each of these may be undef or empty
 		my $pschema = $_[1] || '';
 		my $ptable = $_[2] || '';
@@ -1060,6 +1064,20 @@
 			KEY_SEQ UPDATE_RULE DELETE_RULE FK_NAME PK_NAME
 			DEFERABILITY UNIQUE_OR_PRIMARY PK_DATA_TYPE FKDATA_TYPE
 		));
+
+		if ($oldname eq 'NAME_lc') {
+			if ($odbc) {
+				for my $col (@ODBC_cols) {
+					$col = lc $col;
+				}
+			}
+			else {
+				for my $col (@CLI_cols) {
+					$col = lc $col;
+				}
+			}
+		}
+
 		return _prepare_from_data('foreign_key_info', $fkinfo, $odbc ? \@ODBC_cols : \@CLI_cols);
 
 	}

Modified: DBD-Pg/trunk/t/03dbmethod.t
==============================================================================
--- DBD-Pg/trunk/t/03dbmethod.t	(original)
+++ DBD-Pg/trunk/t/03dbmethod.t	Mon May 18 10:53:47 2009
@@ -26,7 +26,7 @@
 if (! defined $dbh) {
 	plan skip_all => 'Connection to database failed, cannot continue testing';
 }
-plan tests => 521;
+plan tests => 524;
 
 isnt ($dbh, undef, 'Connect to database for database handle method testing');
 
@@ -1020,6 +1020,28 @@
 $expected = [$fk3,$fk1,$fk2,$fk5,$fk6,$fk7];
 is_deeply ($result, $expected, $t);
 
+$t='DB handle method "foreign_key_info" works with FetchHashKeyName NAME_lc';
+$dbh->{FetchHashKeyName} = 'NAME_lc';
+$sth = $dbh->foreign_key_info(undef,undef,$table1,undef,undef,$table2);
+$sth->execute();
+$result = $sth->fetchrow_hashref();
+$sth->finish();
+ok (exists $result->{'fk_table_name'}, $t);
+
+$t='DB handle method "foreign_key_info" works with FetchHashKeyName NAME_uc';
+$dbh->{FetchHashKeyName} = 'NAME_uc';
+$sth = $dbh->foreign_key_info(undef,undef,$table1,undef,undef,$table2);
+$sth->execute();
+$result = $sth->fetchrow_hashref();
+ok (exists $result->{'FK_TABLE_NAME'}, $t);
+
+$t='DB handle method "foreign_key_info" works with FetchHashKeyName NAME';
+$dbh->{FetchHashKeyName} = 'NAME';
+$sth = $dbh->foreign_key_info(undef,undef,$table1,undef,undef,$table2);
+$sth->execute();
+$result = $sth->fetchrow_hashref();
+ok (exists $result->{'FK_TABLE_NAME'}, $t);
+
 # Clean everything up
 {
 	$dbh->do('DROP TABLE dbd_pg_test3');
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.