Skip Menu |

This queue is for tickets about the DateTime-Format-DBI CPAN distribution.

Report information
The Basics
Id: 61614
Status: resolved
Worked: 2 hours (120 min)
Priority: 0/
Queue: DateTime-Format-DBI

People
Owner: CFAERBER [...] cpan.org
Requestors: BRAD [...] cpan.org
Cc: BRAD [...] cpan.org
AdminCc:

Bug Information
Severity: Important
Broken in: 0.035
Fixed in:
  • 0.039_20101017
  • 0.039_20101018
  • 0.040



CC: BRAD [...] cpan.org
Subject: [patch] Oracle/Sybase support
G'day, when using DateTime::Format::DBI for Sybase or Oracle handles the call to new() fails - neither of DateTime::Format::Sybase and DateTime::Format::Oracle returns an object. The attached patch modifies new() to return the names of the modules for DateTime::Format::Sybase and DateTime::Format::Oracle rather than trying to instantiate an object. It works around the problem, however a more robust solution may be to have new() instantiate a DateTime::Format::DBI object and provide methods that will call the corresponding subs in the appropriate module - what do you think? Cheers Brad
Subject: datetime-format-dbi.orasyb.patch
diff -rupN DateTime-Format-DBI-0.035/lib/DateTime/Format/DBI.pm DateTime-Format-DBI-0.035-patched//lib/DateTime/Format/DBI.pm --- DateTime-Format-DBI-0.035/lib/DateTime/Format/DBI.pm 2010-08-01 15:49:36.000000000 +0100 +++ DateTime-Format-DBI-0.035-patched//lib/DateTime/Format/DBI.pm 2010-09-24 16:28:21.000000000 +0100 @@ -1,4 +1,5 @@ package DateTime::Format::DBI; + # $Id: DBI.pm 4451 2010-08-01 14:49:22Z cfaerber $ use strict; @@ -12,6 +13,7 @@ $VERSION = '0.035'; $VERSION = eval { $VERSION }; our %db_to_parser = ( + # lowercase for case-insensitivity! 'mysql' => 'DateTime::Format::MySQL', 'pg' => 'DateTime::Format::Pg', @@ -26,18 +28,22 @@ sub new { my ($name,$dbh) = @_; UNIVERSAL::isa($dbh,'DBI::db') || croak('Not a DBI handle.'); -# my $dbtype = $dbh->{Driver}->{Name}; - my @dbtypes = eval { DBI::_dbtype_names($dbh) }; - my $dbtype = shift @dbtypes; + my $dbtype = $dbh->{Driver}->{Name}; +# my @dbtypes = eval { DBI::_dbtype_names($dbh) }; +# my $dbtype = shift @dbtypes; my $pclass = $db_to_parser{lc $dbtype}; $pclass || croak("Unsupported database driver '".$dbtype."'"); + eval "use $pclass;"; - my $parser = eval "use $pclass; $pclass->new();"; - - $parser || croak("Cannot load $pclass"); - - return $parser; + # Oracle and Sybase use a static class for DateTime::Format. + if ( lc $dbtype eq 'oracle' || lc $dbtype eq 'sybase' ) { + return $pclass; + } + else { + return $pclass->new() + || croak("Cannot load $pclass"); + } } =head1 NAME
On 2010-09-24T11:30:50-04:00, BRAD wrote: Show quoted text
> G'day, when using DateTime::Format::DBI for Sybase or Oracle handles the > call to new() fails - neither of DateTime::Format::Sybase and > DateTime::Format::Oracle returns an object.
Thanks for reporting this bug. Sorry for the delay in answering I'm not sure whether returning a DT::F::DBI object would be the right thing to do. Some DB specific modules have more than the usual parse/format_datetime functions, so I'd have to either use AUTOLOAD or create a subclass on-the-fly. Claus
experimental fix in DateTime-Format-DBI-0.039_20101017: checks whether the class can('new')
On Fri Oct 15 10:02:10 2010, CFAERBER wrote: Show quoted text
> On 2010-09-24T11:30:50-04:00, BRAD wrote:
> > G'day, when using DateTime::Format::DBI for Sybase or Oracle handles
> the
> > call to new() fails - neither of DateTime::Format::Sybase and > > DateTime::Format::Oracle returns an object.
> > Thanks for reporting this bug. Sorry for the delay in answering > > I'm not sure whether returning a DT::F::DBI object would be the right > thing to do. Some DB > specific modules have more than the usual parse/format_datetime > functions, so I'd have to > either use AUTOLOAD or create a subclass on-the-fly. > > Claus
G'day Claus, No worries - I was thinking of maybe returning a very light object from new(), containing either an instance of the target parser or just the class name, and then 4 methods that wrap calls to parse/format datetime/duration. Using AUTOLOAD may well be a more elegant solution in terms of allowing users access to other functions. It'd reduce the size of the module too. I forgot to mention too, the modification I made to the code that determines the DB type (uncommenting 'my $dbtype = $dbh->{Driver}->{Name};' and commenting the subsequent two lines) was to work around an annoying error when used with DBD::Sybase and DBD::Oracle; I don't know whether that broke other DB types though. When I'm at work tomorrow I'll hunt out the precise error message and maybe think about a more robust fix. Cheers (and thanks for writing this module in the first place!) Brad
On Sun Oct 17 07:22:46 2010, BRAD wrote: Show quoted text
> On Fri Oct 15 10:02:10 2010, CFAERBER wrote:
> > On 2010-09-24T11:30:50-04:00, BRAD wrote:
> > > G'day, when using DateTime::Format::DBI for Sybase or Oracle handles
> > the
> > > call to new() fails - neither of DateTime::Format::Sybase and > > > DateTime::Format::Oracle returns an object.
> > > > Thanks for reporting this bug. Sorry for the delay in answering > > > > I'm not sure whether returning a DT::F::DBI object would be the right > > thing to do. Some DB > > specific modules have more than the usual parse/format_datetime > > functions, so I'd have to > > either use AUTOLOAD or create a subclass on-the-fly. > > > > Claus
> > G'day Claus, > > No worries - I was thinking of maybe returning a very light object from > new(), containing either an instance of the target parser or just the > class name, and then 4 methods that wrap calls to parse/format > datetime/duration. > > Using AUTOLOAD may well be a more elegant solution in terms of allowing > users access to other functions. It'd reduce the size of the module too. > > I forgot to mention too, the modification I made to the code that > determines the DB type (uncommenting 'my $dbtype = > $dbh->{Driver}->{Name};' and commenting the subsequent two lines) was to > work around an annoying error when used with DBD::Sybase and > DBD::Oracle; I don't know whether that broke other DB types though. When > I'm at work tomorrow I'll hunt out the precise error message and maybe > think about a more robust fix. > > Cheers (and thanks for writing this module in the first place!) > > Brad
G'day again, This is the error message using the unadulterated version of the module: Use of uninitialized value $DbTypeSubclass in concatenation (.) or string at /usr/lib/site_perl/5.10.1/x86_64-linux-thread-multi/DBI.pm line 944. This occurs with both Sybase and Oracle. Modifying it to use 'my $dbtype = $dbh->{Driver}->{Name};' solves the issue; as I said, I don't know whether that then breaks other DB drivers. Cheers Brad
Subject: Re: [rt.cpan.org #61614] [patch] Oracle/Sybase support
Date: Mon, 18 Oct 2010 11:38:48 +0200
To: bug-DateTime-Format-DBI [...] rt.cpan.org
From: Claus Färber <CFAERBER [...] cpan.org>
Hi! Am 2010-10-18 um 11:16 schrieb Brad Macpherson via RT: Show quoted text
> This is the error message using the unadulterated version of the module: > > Use of uninitialized value $DbTypeSubclass in concatenation (.) or > string at /usr/lib/site_perl/5.10.1/x86_64-linux-thread-multi/DBI.pm > line 944.
This warning has recently been fixed, in version 0.036. Show quoted text
> This occurs with both Sybase and Oracle. Modifying it to use 'my $dbtype > = $dbh->{Driver}->{Name};' solves the issue; as I said, I don't know > whether that then breaks other DB drivers.
It breaks code that uses proxies, ODBC or similar interface layers. DBI already has code to determine the underlying DB type. I don't want to duplicate that. Claus
On Mon Oct 18 05:39:00 2010, CFAERBER wrote: Show quoted text
> Hi! > > Am 2010-10-18 um 11:16 schrieb Brad Macpherson via RT:
> > This is the error message using the unadulterated version of the
> module:
> > > > Use of uninitialized value $DbTypeSubclass in concatenation (.) or > > string at /usr/lib/site_perl/5.10.1/x86_64-linux-thread-multi/DBI.pm > > line 944.
> > This warning has recently been fixed, in version 0.036. >
> > This occurs with both Sybase and Oracle. Modifying it to use 'my
> $dbtype
> > = $dbh->{Driver}->{Name};' solves the issue; as I said, I don't know > > whether that then breaks other DB drivers.
> > It breaks code that uses proxies, ODBC or similar interface layers. > DBI already has code to determine the underlying DB type. I don't want > to duplicate that. > > Claus
Excellent - fair enough too. I've updated my test rig to 0.036, and sure enough the DbTypeSubclass errors have gone away. Of course, the main error in this ticket came back :-) so I installed your test fix. It looks as though that's solved it! Cheers Brad
G'day again Claus, That's worked a treat - for Sybase and Oracle I can confirm that the release http://search.cpan.org/CPAN/authors/id/C/CF/CFAERBER/DateTime-Format-DBI-0.039_20101018.tar.gz works perfectly. Cheers Brad
Subject: Re: [rt.cpan.org #61614] [patch] Oracle/Sybase support
Date: Tue, 19 Oct 2010 17:41:24 +0200
To: bug-DateTime-Format-DBI [...] rt.cpan.org
From: Claus Färber <CFAERBER [...] cpan.org>
Am 2010-10-19 um 12:57 schrieb Brad Macpherson via RT: Show quoted text
> That's worked a treat - for Sybase and Oracle I can confirm that the > release > http://search.cpan.org/CPAN/authors/id/C/CF/CFAERBER/DateTime-Format-DBI-0.039_20101018.tar.gz > works perfectly.
Thanks. That was the last information I needed for releasing it as 0.040. (Lacking an Oracle or Sybase server, I can't test it myself.) Claus
On Tue Oct 19 11:41:44 2010, CFAERBER wrote: Show quoted text
> Am 2010-10-19 um 12:57 schrieb Brad Macpherson via RT:
> > That's worked a treat - for Sybase and Oracle I can confirm that the > > release > > http://search.cpan.org/CPAN/authors/id/C/CF/CFAERBER/DateTime-
> Format-DBI-0.039_20101018.tar.gz
> > works perfectly.
> > Thanks. That was the last information I needed for releasing it as > 0.040. (Lacking an Oracle or Sybase server, I can't test it myself.) > > Claus
I'd be happy to test against Oracle and Sybase if you want to let me know when new versions are released. Cheers Brad
Subject: Re: [rt.cpan.org #61614] [patch] Oracle/Sybase support
Date: Mon, 1 Nov 2010 23:12:44 +0100
To: bug-DateTime-Format-DBI [...] rt.cpan.org
From: Claus Färber <CFAERBER [...] cpan.org>
Am 2010-10-24 um 14:26 schrieb Brad Macpherson via RT: Show quoted text
> On Tue Oct 19 11:41:44 2010, CFAERBER wrote:
>> Thanks. That was the last information I needed for releasing it as >> 0.040. (Lacking an Oracle or Sybase server, I can't test it myself.)
> > I'd be happy to test against Oracle and Sybase if you want to let me > know when new versions are released.
Thank you for your offer. I'll keep that in mind. Claus