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

gphat at dev.catalyst.perl.org gphat at dev.catalyst.perl.org
Tue Jun 19 22:07:40 GMT 2007


Author: gphat
Date: 2007-06-19 22:07:39 +0100 (Tue, 19 Jun 2007)
New Revision: 3513

Modified:
   trunk/DBIx-Class/Changes
   trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm
   trunk/DBIx-Class/t/81transactions.t
Log:
Call ensure_connected in txn_begin to avoid stomping on the transaction depth


Modified: trunk/DBIx-Class/Changes
===================================================================
--- trunk/DBIx-Class/Changes	2007-06-19 17:58:03 UTC (rev 3512)
+++ trunk/DBIx-Class/Changes	2007-06-19 21:07:39 UTC (rev 3513)
@@ -1,5 +1,7 @@
 Revision history for DBIx::Class
 
+        - ensure_connected before txn_begin to catch stomping on transaction
+          depth
         - new method "rethrow" for our exception objects
 
 0.08001 2007-06-17 21:21:02

Modified: trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm	2007-06-19 17:58:03 UTC (rev 3512)
+++ trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm	2007-06-19 21:07:39 UTC (rev 3513)
@@ -788,6 +788,7 @@
 
 sub txn_begin {
   my $self = shift;
+  $self->ensure_connected();
   if($self->{transaction_depth}++ == 0) {
     $self->debugobj->txn_begin()
       if $self->debug;

Modified: trunk/DBIx-Class/t/81transactions.t
===================================================================
--- trunk/DBIx-Class/t/81transactions.t	2007-06-19 17:58:03 UTC (rev 3512)
+++ trunk/DBIx-Class/t/81transactions.t	2007-06-19 21:07:39 UTC (rev 3513)
@@ -7,7 +7,7 @@
 
 my $schema = DBICTest->init_schema();
 
-plan tests => 39;
+plan tests => 40;
 
 my $code = sub {
   my ($artist, @cd_titles) = @_;
@@ -178,3 +178,13 @@
   ok(!defined($cd), q{failed txn_do didn't add failed txn's cd});
 }
 
+# Grab a new schema to test txn before connect
+{
+    my $schema2 = DBICTest->init_schema(no_deploy => 1);
+    eval {
+        $schema2->txn_begin();
+        $schema2->txn_begin();
+    };
+    my $err = $@;
+    ok(($err eq ''), 'Pre-connection nested transactions.');
+}




More information about the Bast-commits mailing list