Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: chris.winters [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.43_1
Fixed in: 1.44



Subject: Timestamp type not properly quoted with $dbh->quote
The $dbh->quote( $value, $type ) method doesn't properly quote the $value when the $type is '93', or what DBD::Pg returns for 'TIMESTAMP' fields. The attached test shows this. Running on: DBI: 1.48, DBD::Pg 1.43_1, Perl 5.8.6 (no threads), Linux 2.6.13
# -*-perl-*- use strict; use DBI; use Test::More tests => 2; my $dsn = $ENV{DBI_DSN} || 'DBI:Pg:dbname=test'; my $user = $ENV{DBI_USER} || 'postgres'; my $pass = $ENV{DBI_PASS} || 'postgres'; my $dbh = DBI->connect( $dsn, $user, $pass ) || die "Cannot connect to '$dsn': $DBI::errstr"; my $create_sql = <<SQL; CREATE TABLE timestamp_test ( id INT NOT NULL, ts TIMESTAMP NOT NULL, PRIMARY KEY( id ) ) SQL $dbh->do( $create_sql ); my $fetch_sql = 'SELECT * FROM timestamp_test WHERE 1 = 0'; my $sth = $dbh->prepare( $fetch_sql ); $sth->execute; my $ts_type = $sth->{TYPE}->[1]; my $date_to_quote = '2005-10-15 12:12:12'; is( $dbh->quote( $date_to_quote ), qq{'$date_to_quote'}, "Quoted value without field type" ); is( $dbh->quote( $date_to_quote, $ts_type ), qq{'$date_to_quote'}, "Quoted value with field type" ); $dbh->do( 'DROP TABLE timestamp_test' );