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

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Wed Jul 18 00:18:26 GMT 2007


Author: matthewt
Date: 2007-07-18 00:18:25 +0100 (Wed, 18 Jul 2007)
New Revision: 3590

Modified:
   trunk/DBIx-Class/Changes
   trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm
   trunk/DBIx-Class/t/92storage.t
Log:
non-destructive hashref handling for connect_info options

Modified: trunk/DBIx-Class/Changes
===================================================================
--- trunk/DBIx-Class/Changes	2007-07-17 23:07:06 UTC (rev 3589)
+++ trunk/DBIx-Class/Changes	2007-07-17 23:18:25 UTC (rev 3590)
@@ -1,5 +1,6 @@
 Revision history for DBIx::Class
 
+        - non-destructive hashref handling for connect_info options
         - count no longer returns negative values after slice
           (report and test from JOHANL)
         - rebless before building datetime_parser

Modified: trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm	2007-07-17 23:07:06 UTC (rev 3589)
+++ trunk/DBIx-Class/lib/DBIx/Class/Storage/DBI.pm	2007-07-17 23:18:25 UTC (rev 3590)
@@ -479,6 +479,7 @@
 
   my $last_info = $dbi_info->[-1];
   if(ref $last_info eq 'HASH') {
+    $last_info = { %$last_info }; # so delete is non-destructive
     for my $storage_opt (qw/on_connect_do disable_sth_caching unsafe/) {
       if(my $value = delete $last_info->{$storage_opt}) {
         $self->$storage_opt($value);
@@ -489,6 +490,8 @@
         $self->_sql_maker_opts->{$sql_maker_opt} = $opt_val;
       }
     }
+    # re-insert modified hashref
+    $dbi_info->[-1] = $last_info;
 
     # Get rid of any trailing empty hashref
     pop(@$dbi_info) if !keys %$last_info;

Modified: trunk/DBIx-Class/t/92storage.t
===================================================================
--- trunk/DBIx-Class/t/92storage.t	2007-07-17 23:07:06 UTC (rev 3589)
+++ trunk/DBIx-Class/t/92storage.t	2007-07-17 23:18:25 UTC (rev 3590)
@@ -32,7 +32,7 @@
     }
 }
 
-plan tests => 5;
+plan tests => 6;
 
 my $schema = DBICTest->init_schema();
 
@@ -64,5 +64,10 @@
 is(1, $schema->resultset('Artist')->search({name => "Exploding Sheep" })->count,
   "And the STH was retired");
 
+my $info = { on_connect_do => [] };
 
+$storage->connect_info(['foo','bar','baz',$info]);
+
+ok(exists($info->{on_connect_do}), q{Didn't kill key passed to storage});
+
 1;




More information about the Bast-commits mailing list