Skip Menu |

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

Report information
The Basics
Id: 20282
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: cpan [...] ubc.pkts.ca
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.49
Fixed in: 2.0.0



Subject: Bug in column_info: quotes not removed
If a field name is a reserved word for postgres (eg: 'location'), postgres will put double-quotes around it in the output of pg_dump, and DBD::Pg will do it in the results of a column_info() call. As functions like selectrow_hashref don't seem to have the double-quotes, a problem occurs when you're using column_info to set up web page fields (mainly their widths) for selectrow_hashref to fill in: the hash keys won't match. (location != "location") If you could remove the quotes around field names in the column_info() call, that'd be great! I'm currently using this code to do it: foreach (keys %result) { if (m/"/) { my $n=$_; $n=~s/"//g; $result{$n}=$result{$_}; delete $result{$_}; } } Thanks!
From: cpan [...] ubc.pkts.ca
I've tweaked the example a little: my $aa; my $sth=$dbh->column_info("mydatabase","public",$table,"%"); my %fields=%{$sth->fetchall_hashref("COLUMN_NAME")}; %fields=map {$aa=$_;s/^"(.*)"$/$1/g;$_=>$fields{$aa}} keys %fields; print Dumper(\%fields); This is perl 5.8.8, perl-DBD-Pg-1.49-1.FC5.i386.rpm from Fedora Core 5.
While we can't add a flag in, unfortunately, I did add some new fields that return the unescaped versions: pg_schema, pg_table, and pg_column. Committed in r10497 if you wish to try them out.
Subject: Re: [rt.cpan.org #20282] Bug in column_info: quotes not removed
Date: Tue, 08 Jan 2008 22:42:23 -0800
To: bug-DBD-Pg [...] rt.cpan.org
From: PF <kernel [...] pkts.ca>
On Tue, 2008-01-08 at 15:48 -0500, Greg Sabino Mullane via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=20282 > > > While we can't add a flag in, unfortunately, I did add some new fields > that return the unescaped versions: pg_schema, pg_table, and pg_column. > Committed in r10497 if you wish to try them out.
I was thinking that it was more a bug than a feature: two different routines return different values for the same information. Hopefully they could be made consistent, and preferably also consistent with external programs, like pg_dump in this case. I appreciate that you've worked on the problem. Can you give me an example on how to use the new fields? I'm not sure where I should use them. (It's also been 1 1/2 years since the bug report; I'm not working on that project or for that customer any more.) Thanks! -- PF <kernel@pkts.ca>
As an example, the previous code would be changed to: my %fields=%{$sth->fetchall_hashref("pg_column")};