[Bast-commits] r7260 - in DBIx-Class/0.08/branches/reduce_pings: lib/DBIx/Class/Storage t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Sat Aug 8 15:40:21 GMT 2009


Author: ribasushi
Date: 2009-08-08 15:40:19 +0000 (Sat, 08 Aug 2009)
New Revision: 7260

Modified:
   DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/reduce_pings/t/92storage_ping_count.t
Log:
A more straightforward txn_begin fix, some more test fixes

Modified: DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI.pm	2009-08-08 15:02:39 UTC (rev 7259)
+++ DBIx-Class/0.08/branches/reduce_pings/lib/DBIx/Class/Storage/DBI.pm	2009-08-08 15:40:19 UTC (rev 7260)
@@ -530,15 +530,8 @@
 
   local $self->{_in_dbh_do} = 1;
 
-  $self->_do_with_reconnect($code, @_);
-}
-
-sub _do_with_reconnect {
-  my $self = shift;
-  my $code = shift;
   my @result;
   my $want_array = wantarray;
-  my $dbh = $self->_dbh;
 
   eval {
     $self->_verify_pid if $dbh;
@@ -608,7 +601,7 @@
     my $exception = $@;
     if(!$exception) { return $want_array ? @result : $result[0] }
 
-    if($tried++ > 0 || $self->connected) {
+    if($tried++ || $self->connected) {
       eval { $self->txn_rollback };
       my $rollback_exception = $@;
       if($rollback_exception) {
@@ -1060,10 +1053,14 @@
   if($self->{transaction_depth} == 0) {
     $self->debugobj->txn_begin()
       if $self->debug;
-    # this isn't ->_dbh-> because
-    #  we should reconnect on begin_work
-    #  for AutoCommit users
-    $self->_do_with_reconnect(sub { $_[1]->begin_work });
+
+    # being here implies we have AutoCommit => 1
+    # if the user is utilizing txn_do - good for
+    # him, otherwise we need to ensure that the
+    # $dbh is healthy on BEGIN
+    my $dbh_method = $self->{_in_dbh_do} ? '_dbh' : 'dbh';
+    $self->$dbh_method->begin_work;
+
   } elsif ($self->auto_savepoint) {
     $self->svp_begin;
   }

Modified: DBIx-Class/0.08/branches/reduce_pings/t/92storage_ping_count.t
===================================================================
--- DBIx-Class/0.08/branches/reduce_pings/t/92storage_ping_count.t	2009-08-08 15:02:39 UTC (rev 7259)
+++ DBIx-Class/0.08/branches/reduce_pings/t/92storage_ping_count.t	2009-08-08 15:40:19 UTC (rev 7260)
@@ -1,20 +1,14 @@
 use strict;
 use warnings;  
 
-# Stolen from 76joins.t (a good test for this purpose)
-
 use Test::More;
 use lib qw(t/lib);
 use DBICTest;
 use Data::Dumper;
 use DBIC::SqlMakerTest;
 
-plan tests => 1;
-
 my $ping_count = 0;
 
-my $schema = DBICTest->init_schema();
-
 {
   local $SIG{__WARN__} = sub {};
   require DBIx::Class::Storage::DBI;
@@ -27,6 +21,19 @@
   };
 }
 
+
+# We do not count pings during deploy() because of the flux
+# around sqlt. Eventually there should be no pings at all
+my $schema = DBICTest->init_schema( sqlite_use_file => 1, no_populate => 1 );
+
+TODO: {
+  local $TODO = 'Unable to fix before proper deploy() error handling';
+  is ($ping_count, 0, 'no _ping() calls during deploy');
+  $ping_count = 0;
+}
+
+DBICTest->populate_schema ($schema);
+
 # perform some operations and make sure they don't ping
 
 $schema->resultset('CD')->create({
@@ -52,3 +59,5 @@
 });
 
 is $ping_count, 0, 'no _ping() calls';
+
+done_testing;




More information about the Bast-commits mailing list