[Bast-commits] r3586 - in trunk/DBIx-Class: . lib/DBIx lib/DBIx/Class/Storage t

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Mon Jul 16 15:46:39 GMT 2007


Author: matthewt
Date: 2007-07-16 15:46:38 +0100 (Mon, 16 Jul 2007)
New Revision: 3586

Modified:
   trunk/DBIx-Class/Changes
   trunk/DBIx-Class/lib/DBIx/Class.pm
   trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm
   trunk/DBIx-Class/t/72pg.t
Log:
fixup for datetime parser from Matt Lawrence (mattlaw)

Modified: trunk/DBIx-Class/Changes
===================================================================
--- trunk/DBIx-Class/Changes	2007-07-16 11:49:16 UTC (rev 3585)
+++ trunk/DBIx-Class/Changes	2007-07-16 14:46:38 UTC (rev 3586)
@@ -1,5 +1,8 @@
 Revision history for DBIx::Class
 
+        - rebless before building datetime_parser
+          (patch from mattlaw / Matt Lawrence)
+
 0.08003 2007-07-14 18:01:00
         - improved populate bulk_insert mode
         - fixed up multi_create to be more intelligent about PK<->PK rels

Modified: trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm	2007-07-16 11:49:16 UTC (rev 3585)
+++ trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm	2007-07-16 14:46:38 UTC (rev 3586)
@@ -1428,7 +1428,10 @@
 
 sub datetime_parser {
   my $self = shift;
-  return $self->{datetime_parser} ||= $self->build_datetime_parser(@_);
+  return $self->{datetime_parser} ||= do {
+    $self->ensure_connected;
+    $self->build_datetime_parser(@_);
+  };
 }
 
 =head2 datetime_parser_type

Modified: trunk/DBIx-Class/lib/DBIx/Class.pm
===================================================================
--- trunk/DBIx-Class/lib/DBIx/Class.pm	2007-07-16 11:49:16 UTC (rev 3585)
+++ trunk/DBIx-Class/lib/DBIx/Class.pm	2007-07-16 14:46:38 UTC (rev 3586)
@@ -233,6 +233,8 @@
 
 LTJake: Brian Cassidy <bricas at cpan.org>
 
+mattlaw: Matt Lawrence
+
 ned: Neil de Carteret
 
 nigel: Nigel Metheringham <nigelm at cpan.org>

Modified: trunk/DBIx-Class/t/72pg.t
===================================================================
--- trunk/DBIx-Class/t/72pg.t	2007-07-16 11:49:16 UTC (rev 3585)
+++ trunk/DBIx-Class/t/72pg.t	2007-07-16 14:46:38 UTC (rev 3586)
@@ -27,11 +27,23 @@
 plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
  . ' (note: creates and drops tables named artist and casecheck!)' unless ($dsn && $user);
 
-plan tests => 8;
+plan tests => 10;
 
 DBICTest::Schema->load_classes( 'Casecheck' );
 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
 
+# Check that datetime_parser returns correctly before we explicitly connect.
+SKIP: {
+    eval { require DateTime::Format::Pg };
+    skip "DateTime::Format::Pg required", 2 if $@;
+
+    my $store = ref $schema->storage;
+    is($store, 'DBIx::Class::Storage::DBI', 'Started with generic storage');
+
+    my $parser = $schema->storage->datetime_parser;
+    is( $parser, 'DateTime::Format::Pg', 'datetime_parser is as expected');
+}
+
 my $dbh = $schema->storage->dbh;
 $schema->source("Artist")->name("testschema.artist");
 $dbh->do("CREATE SCHEMA testschema;");




More information about the Bast-commits mailing list