Fix datetimes in ODBC/Firebird (merge identical code left after a870aa85e)
Peter Rabbitson [Thu, 30 Jan 2014 12:00:41 +0000 (13:00 +0100)]
Changes
lib/DBIx/Class/Storage/DBI/Firebird/Common.pm
lib/DBIx/Class/Storage/DBI/InterBase.pm
lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm

diff --git a/Changes b/Changes
index 43506af..d2dea57 100644 (file)
--- 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
index 4676fc4..b665e75 100644 (file)
@@ -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
index 5f5043b..cb6d8f9 100644 (file)
@@ -30,10 +30,6 @@ L</connect_call_datetime_setup>.
 
 =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
index ac0afbb..095f416 100644 (file)
@@ -31,8 +31,6 @@ makes it more suitable for long running processes such as under L<Catalyst>.
 
 =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<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.