r64011 - in /branches/upstream/libdatetime-format-dbi-perl/current: Build.PL Changes MANIFEST MANIFEST.SKIP META.yml SIGNATURE lib/DateTime/Format/DBI.pm t/withtestdb.t

periapt-guest at users.alioth.debian.org periapt-guest at users.alioth.debian.org
Tue Oct 19 20:52:24 UTC 2010


Author: periapt-guest
Date: Tue Oct 19 20:49:14 2010
New Revision: 64011

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=64011
Log:
[svn-upgrade] new version libdatetime-format-dbi-perl (0.040)

Added:
    branches/upstream/libdatetime-format-dbi-perl/current/MANIFEST.SKIP
    branches/upstream/libdatetime-format-dbi-perl/current/t/withtestdb.t
Modified:
    branches/upstream/libdatetime-format-dbi-perl/current/Build.PL
    branches/upstream/libdatetime-format-dbi-perl/current/Changes
    branches/upstream/libdatetime-format-dbi-perl/current/MANIFEST
    branches/upstream/libdatetime-format-dbi-perl/current/META.yml
    branches/upstream/libdatetime-format-dbi-perl/current/SIGNATURE
    branches/upstream/libdatetime-format-dbi-perl/current/lib/DateTime/Format/DBI.pm

Modified: branches/upstream/libdatetime-format-dbi-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-dbi-perl/current/Build.PL?rev=64011&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-dbi-perl/current/Build.PL (original)
+++ branches/upstream/libdatetime-format-dbi-perl/current/Build.PL Tue Oct 19 20:49:14 2010
@@ -23,15 +23,11 @@
 		'DBI'		=> 1.21,
 	},
 	'recommends'	=> {
+		'Test::Database' => 0,
 	},
 	'build_requires' => {
 		'Test::More' => 0, 
 		'Test::NoWarnings' => 0,
-	},
-
-	auto_features => { 
-		map { make_feature($_) } 
-			keys %{$db} 
 	},
 	'no_index' => {
 		'directory' => 'eg'
@@ -44,11 +40,3 @@
 );
 
 $b->create_build_script;
-
-sub make_feature {
-  my $dbname = $db->{shift};
-  return ( (lc $dbname).'_support' => {
-	'description'	=> 'support for DateTime::Format::'.$dbname,
-	'requires'	=> { 'DateTime::Format::'.$dbname => shift || 0 }
-    })
-}

Modified: branches/upstream/libdatetime-format-dbi-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-dbi-perl/current/Changes?rev=64011&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-dbi-perl/current/Changes (original)
+++ branches/upstream/libdatetime-format-dbi-perl/current/Changes Tue Oct 19 20:49:14 2010
@@ -1,4 +1,9 @@
 Revision history for Perl extension DateTime::Format::DBI.
+
+0.040 Tue Oct 19 00:00:00 2010
+	- add tests with Test::Database
+	- support DT::F:: modules that are singletons,
+	  fixes #61614: [patch] Oracle/Sybase support
 
 0.036 Fri Oct 15 00:00:00 2010
 	- fix warning generated by DBI (reported by Ted Byers)
@@ -42,4 +47,4 @@
 	- supports DBD::mysql and DateTime::Format::MySQL
 	- supports DBD::Pg and DateTime::Format::Pg
 
-$Id: Changes 4454 2010-10-15 12:21:12Z cfaerber $
+$Id: Changes 4457 2010-10-19 13:35:13Z cfaerber $

Modified: branches/upstream/libdatetime-format-dbi-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-dbi-perl/current/MANIFEST?rev=64011&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-dbi-perl/current/MANIFEST (original)
+++ branches/upstream/libdatetime-format-dbi-perl/current/MANIFEST Tue Oct 19 20:49:14 2010
@@ -1,13 +1,15 @@
+Build.PL
+Changes
+lib/DateTime/Format/DBI.pm
+LICENSE
+Makefile.PL
+MANIFEST
+MANIFEST.SKIP
+META.yml
 README
-Changes
-LICENSE
-MANIFEST
-Build.PL
-lib/DateTime/Format/DBI.pm
 t/00basic.t
 t/10pod.t
 t/11pod_cover.t
 t/withsqlite.t
-Makefile.PL
-META.yml
+t/withtestdb.t
 SIGNATURE    Added here by Module::Build

Added: branches/upstream/libdatetime-format-dbi-perl/current/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-dbi-perl/current/MANIFEST.SKIP?rev=64011&op=file
==============================================================================
--- branches/upstream/libdatetime-format-dbi-perl/current/MANIFEST.SKIP (added)
+++ branches/upstream/libdatetime-format-dbi-perl/current/MANIFEST.SKIP Tue Oct 19 20:49:14 2010
@@ -1,0 +1,9 @@
+^MYMETA.yml$
+\.svn
+^\.git
+^_build
+^blib
+^Build$
+.*\.tar\.gz$
+MANIFEST.bak
+^sql.*\.tmp$

Modified: branches/upstream/libdatetime-format-dbi-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-dbi-perl/current/META.yml?rev=64011&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-dbi-perl/current/META.yml (original)
+++ branches/upstream/libdatetime-format-dbi-perl/current/META.yml Tue Oct 19 20:49:14 2010
@@ -18,10 +18,12 @@
 provides:
   DateTime::Format::DBI:
     file: lib/DateTime/Format/DBI.pm
-    version: 0.036
+    version: 0.040
+recommends:
+  Test::Database: 0
 requires:
   DBI: 1.21
   DateTime: 0.1
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.036
+version: 0.040

Modified: branches/upstream/libdatetime-format-dbi-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-dbi-perl/current/SIGNATURE?rev=64011&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-dbi-perl/current/SIGNATURE (original)
+++ branches/upstream/libdatetime-format-dbi-perl/current/SIGNATURE Tue Oct 19 20:49:14 2010
@@ -14,22 +14,24 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-SHA1 0a6a063db037ed7dc6b67033dadebb4d0caf7cac Build.PL
-SHA1 ae7971c6f48a774596c5e21e3d7082ffe0ed0136 Changes
+SHA1 1a4f14c2819b5476b06df43656e47dc1319ebe5e Build.PL
+SHA1 68c45a25e1eb2dce7eed9c48d92f9b2570ebe549 Changes
 SHA1 9b37c74ac55bf4a1d347a873f9936ca24cab4f3b LICENSE
-SHA1 3e5957472b74da21fcd54683e8b406ead9d08fe6 MANIFEST
-SHA1 2fd2b5eee5e094294c55696617d605a9b8300c20 META.yml
+SHA1 6eb53866ab9b1a8b60cc7ace6029754d38b755ec MANIFEST
+SHA1 6abdc1ab6f9e378b1a00862050bfedafa9abd139 MANIFEST.SKIP
+SHA1 ed2de489efc73cab1d17e17fc2a011f6f1d64baa META.yml
 SHA1 a7ec0a041d9c1ac4e0a83b18b4c851d5ff90bbf8 Makefile.PL
 SHA1 016c6cdea326d4252bf55ba96f50ee79fe9f9b62 README
-SHA1 dfac20545b9c6efa41b98237674657fd27926c76 lib/DateTime/Format/DBI.pm
+SHA1 34a66f01010ea63d94ae4cff678f82efc9251dff lib/DateTime/Format/DBI.pm
 SHA1 fba84bcb3b8f2c3743fbb79203d181488b293f50 t/00basic.t
 SHA1 331eb58bd820411c7685dfd7aff4d060fdafab5e t/10pod.t
 SHA1 94cbaa3da22888098b42d4affce837e3b45ccfef t/11pod_cover.t
 SHA1 16c19824b373d192db666cac33ecbcf1d5102bbf t/withsqlite.t
+SHA1 987f46bc44c8968f5cde9650fc3a5768da5f3a70 t/withtestdb.t
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.10 (Darwin)
 
-iEYEARECAAYFAky4R0AACgkQSKUOY2OWgPDXxwCfUkTx5fFqz7T1nnICVw/G6DNI
-HTkAoIiBaNP0/6sIgz2qjvgZr1NO+XyH
-=K91a
+iEYEARECAAYFAky9nqUACgkQSKUOY2OWgPCQjwCfRR3ku4XdJEfNMDEf7ZTiRQTd
+VDYAoKWIaPcE4csA4FW3D4eghgE5KgSk
+=8xgF
 -----END PGP SIGNATURE-----

Modified: branches/upstream/libdatetime-format-dbi-perl/current/lib/DateTime/Format/DBI.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-dbi-perl/current/lib/DateTime/Format/DBI.pm?rev=64011&op=diff
==============================================================================
--- branches/upstream/libdatetime-format-dbi-perl/current/lib/DateTime/Format/DBI.pm (original)
+++ branches/upstream/libdatetime-format-dbi-perl/current/lib/DateTime/Format/DBI.pm Tue Oct 19 20:49:14 2010
@@ -1,5 +1,5 @@
 package DateTime::Format::DBI;
-# $Id: DBI.pm 4454 2010-10-15 12:21:12Z cfaerber $
+# $Id: DBI.pm 4457 2010-10-19 13:35:13Z cfaerber $
 
 use strict;
 use vars qw ($VERSION);
@@ -8,7 +8,7 @@
 use Carp;
 use DBI 1.21;
 
-$VERSION = '0.036';
+$VERSION = '0.040';
 $VERSION = eval { $VERSION };
 
 our %db_to_parser = (
@@ -17,25 +17,58 @@
   'pg'		=> 'DateTime::Format::Pg',
   'db2'		=> 'DateTime::Format::DB2',
   'mssql'	=> 'DateTime::Format::MSSQL',  # experimental
-  'oracle'	=> 'DateTime::Format::Oracle', # experimental
-  'sqlite'	=> 'DateTime::Format::SQLite', # experimental
-  'sybase'	=> 'DateTime::Format::Sybase', # experimental
+  'oracle'	=> 'DateTime::Format::Oracle',
+  'sqlite'	=> 'DateTime::Format::SQLite',
+  'sybase'	=> 'DateTime::Format::Sybase',
 );
+
+sub _get_parser {
+  while(@_) {
+    my $dbt = lc shift;
+    return $db_to_parser{$dbt}
+      if exists $db_to_parser{$dbt};
+  }
+  return undef;
+}
 
 sub new {
   my ($name,$dbh) = @_;
   UNIVERSAL::isa($dbh,'DBI::db') || croak('Not a DBI handle.');
 
+# NB: Using $dbh->{Driver}->{Name} this call does not work with drivers that
+# connect to multiple differnt types of databases, such as DBD::Proxy,
+# DBD::ODBC, DBD::JDBC,... 
+#
+# DBI already has code to determine the underlying database type, which is NOT
+# trivial. I don't want to duplicate that here (although it's only available
+# through a private API).
+
 # my $dbtype = $dbh->{Driver}->{Name};
+
   my @dbtypes = eval { DBI::_dbtype_names($dbh,0) };
-  my $dbtype = shift @dbtypes;
-
-  my $pclass = $db_to_parser{lc $dbtype};
-  $pclass || croak("Unsupported database driver '".$dbtype."'");
-
-  my $parser = eval "use $pclass; $pclass->new();";
-
-  $parser || croak("Cannot load $pclass");
+  my $pclass = _get_parser(@dbtypes);
+
+  croak("No supported database driver in '@dbtypes'")
+    unless defined $pclass;
+
+  eval "use $pclass;";
+  croak("Cannot load $pclass: $@") if $@;
+
+  ## some db formatters are singletons and don't have 'new'
+  ##
+  my $new = UNIVERSAL::can($pclass, 'new');
+  
+  my $parser; if(ref $new) {
+    $parser = eval { $new->($pclass); };
+    croak "Cannot create object for $pclass: $@" if $@;
+  } else {
+    $parser = $pclass;
+  }
+
+  foreach(('format_datetime', 'parse_datetime')) {
+    croak "$pclass->$_ is missing" 
+      unless UNIVERSAL::can($parser, $_)
+  }
 
   return $parser;
 }

Added: branches/upstream/libdatetime-format-dbi-perl/current/t/withtestdb.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-format-dbi-perl/current/t/withtestdb.t?rev=64011&op=file
==============================================================================
--- branches/upstream/libdatetime-format-dbi-perl/current/t/withtestdb.t (added)
+++ branches/upstream/libdatetime-format-dbi-perl/current/t/withtestdb.t Tue Oct 19 20:49:14 2010
@@ -1,0 +1,49 @@
+# $Id: withtestdb.t 4457 2010-10-19 13:35:13Z cfaerber $
+#
+use strict;
+use warnings;
+
+use Test::More;
+use DateTime::Format::DBI;
+
+eval "use Test::Database;";
+plan skip_all => "Test::Database required for real database test" if $@;
+
+my @dbkeys = sort keys %DateTime::Format::DBI::db_to_parser;
+my @handles = Test::Database->handles;
+
+plan tests => $#dbkeys + 1;
+
+my(@done, at skip);
+
+foreach my $dbkey ( @dbkeys )
+{
+  my($handle,) = grep { lc($_->dbd) eq $dbkey  } @handles;
+
+  subtest "with $dbkey" => sub {
+    if($handle) {
+      push @done, $dbkey;
+      plan tests => 3;
+    } else {
+      push @skip, $dbkey;
+      plan skip_all => "Test::Database not configured for $dbkey";
+    }
+
+    my $dbd = $handle->dbd;
+
+    my $parser = eval { DateTime::Format::DBI->new($handle->dbh); };
+    ok(defined $parser, "generate parser for DBD::$dbd");
+
+    isa_ok($parser, $DateTime::Format::DBI::db_to_parser{lc $dbd}, 
+      "correct parser class for DBD::$dbd");
+
+    isnt($parser->format_datetime(DateTime->now), '',
+      "working parser for DBD::$dbd");
+  }
+}
+
+my @mess;
+push @mess, "tested: @done" if @done;
+push @mess, "skipped: @skip" if @skip;
+
+diag join ", ", @mess;




More information about the Pkg-perl-cvs-commits mailing list