From: Peter Rabbitson Date: Thu, 30 Jan 2014 12:00:41 +0000 (+0100) Subject: Fix datetimes in ODBC/Firebird (merge identical code left after a870aa85e) X-Git-Tag: v0.08270~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e5a62c46fad7960d70c8f7a825e7b10ff6ecf5c6;p=dbsrgits%2FDBIx-Class.git Fix datetimes in ODBC/Firebird (merge identical code left after a870aa85e) --- diff --git a/Changes b/Changes index 43506af..d2dea57 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,8 @@ Revision history for DBIx::Class - Fix 0.08260 regression in DBD::SQLite bound int handling. Inserted data was not affected, but any function <=> integer comparison would have failed (originally fixed way back in 0e773352) + - Fix failure to load DateTime formatter when connecting to Firebird + over ODBC 0.08260 2014-01-28 18:52 (UTC) * New Features diff --git a/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm b/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm index 4676fc4..b665e75 100644 --- a/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm +++ b/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm @@ -24,6 +24,10 @@ __PACKAGE__->_use_insert_returning (1); __PACKAGE__->sql_limit_dialect ('FirstSkip'); __PACKAGE__->sql_quote_char ('"'); +__PACKAGE__->datetime_parser_type( + 'DBIx::Class::Storage::DBI::InterBase::DateTime::Format' +); + sub _sequence_fetch { my ($self, $nextval, $sequence) = @_; @@ -108,6 +112,54 @@ SELECT rdb$get_context('SYSTEM', 'ENGINE_VERSION') FROM rdb$database }); } +package # hide from PAUSE + DBIx::Class::Storage::DBI::InterBase::DateTime::Format; + +my $timestamp_format = '%Y-%m-%d %H:%M:%S.%4N'; # %F %T +my $date_format = '%Y-%m-%d'; + +my ($timestamp_parser, $date_parser); + +sub parse_datetime { + shift; + require DateTime::Format::Strptime; + $timestamp_parser ||= DateTime::Format::Strptime->new( + pattern => $timestamp_format, + on_error => 'croak', + ); + return $timestamp_parser->parse_datetime(shift); +} + +sub format_datetime { + shift; + require DateTime::Format::Strptime; + $timestamp_parser ||= DateTime::Format::Strptime->new( + pattern => $timestamp_format, + on_error => 'croak', + ); + return $timestamp_parser->format_datetime(shift); +} + +sub parse_date { + shift; + require DateTime::Format::Strptime; + $date_parser ||= DateTime::Format::Strptime->new( + pattern => $date_format, + on_error => 'croak', + ); + return $date_parser->parse_datetime(shift); +} + +sub format_date { + shift; + require DateTime::Format::Strptime; + $date_parser ||= DateTime::Format::Strptime->new( + pattern => $date_format, + on_error => 'croak', + ); + return $date_parser->format_datetime(shift); +} + 1; =head1 CAVEATS diff --git a/lib/DBIx/Class/Storage/DBI/InterBase.pm b/lib/DBIx/Class/Storage/DBI/InterBase.pm index 5f5043b..cb6d8f9 100644 --- a/lib/DBIx/Class/Storage/DBI/InterBase.pm +++ b/lib/DBIx/Class/Storage/DBI/InterBase.pm @@ -30,10 +30,6 @@ L. =cut -__PACKAGE__->datetime_parser_type( - 'DBIx::Class::Storage::DBI::InterBase::DateTime::Format' -); - sub _ping { my $self = shift; @@ -135,55 +131,6 @@ sub connect_call_datetime_setup { $self->_get_dbh->{ib_time_all} = 'ISO'; } - -package # hide from PAUSE - DBIx::Class::Storage::DBI::InterBase::DateTime::Format; - -my $timestamp_format = '%Y-%m-%d %H:%M:%S.%4N'; # %F %T -my $date_format = '%Y-%m-%d'; - -my ($timestamp_parser, $date_parser); - -sub parse_datetime { - shift; - require DateTime::Format::Strptime; - $timestamp_parser ||= DateTime::Format::Strptime->new( - pattern => $timestamp_format, - on_error => 'croak', - ); - return $timestamp_parser->parse_datetime(shift); -} - -sub format_datetime { - shift; - require DateTime::Format::Strptime; - $timestamp_parser ||= DateTime::Format::Strptime->new( - pattern => $timestamp_format, - on_error => 'croak', - ); - return $timestamp_parser->format_datetime(shift); -} - -sub parse_date { - shift; - require DateTime::Format::Strptime; - $date_parser ||= DateTime::Format::Strptime->new( - pattern => $date_format, - on_error => 'croak', - ); - return $date_parser->parse_datetime(shift); -} - -sub format_date { - shift; - require DateTime::Format::Strptime; - $date_parser ||= DateTime::Format::Strptime->new( - pattern => $date_format, - on_error => 'croak', - ); - return $date_parser->format_datetime(shift); -} - 1; =head1 CAVEATS diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm index ac0afbb..095f416 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm @@ -31,8 +31,6 @@ makes it more suitable for long running processes such as under L. =cut -__PACKAGE__->datetime_parser_type ('DBIx::Class::Storage::DBI::ODBC::Firebird::DateTime::Format'); - # batch operations in DBD::ODBC 1.35 do not work with the official ODBC driver sub _run_connection_actions { my $self = shift; @@ -61,37 +59,6 @@ sub _exec_svp_rollback { }; } -package # hide from PAUSE - DBIx::Class::Storage::DBI::ODBC::Firebird::DateTime::Format; - -# inherit parse/format date -our @ISA = 'DBIx::Class::Storage::DBI::InterBase::DateTime::Format'; - -my $timestamp_format = '%Y-%m-%d %H:%M:%S.%4N'; # %F %T -my $timestamp_parser; - -sub parse_datetime { - shift; - require DateTime::Format::Strptime; - $timestamp_parser ||= DateTime::Format::Strptime->new( - pattern => $timestamp_format, - on_error => 'croak', - ); - return $timestamp_parser->parse_datetime(shift); -} - -sub format_datetime { - shift; - require DateTime::Format::Strptime; - $timestamp_parser ||= DateTime::Format::Strptime->new( - pattern => $timestamp_format, - on_error => 'croak', - ); - return $timestamp_parser->format_datetime(shift); -} - -1; - =head1 AUTHOR See L and L.