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

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Thu Jun 7 21:16:35 GMT 2007


Author: matthewt
Date: 2007-06-07 21:16:34 +0100 (Thu, 07 Jun 2007)
New Revision: 3477

Modified:
   trunk/DBIx-Class/Changes
   trunk/DBIx-Class/lib/DBIx/Class/Row.pm
   trunk/DBIx-Class/t/68inflate_serialize.t
Log:
test fixups

Modified: trunk/DBIx-Class/Changes
===================================================================
--- trunk/DBIx-Class/Changes	2007-06-06 21:27:39 UTC (rev 3476)
+++ trunk/DBIx-Class/Changes	2007-06-07 20:16:34 UTC (rev 3477)
@@ -1,5 +1,6 @@
 Revision history for DBIx::Class
 
+        - Test cleanup and doc note (ribasushi)
         - More documentation updates
         - Error messages from ->deploy made more informative
         - connect_info will now always return the arguments it was

Modified: trunk/DBIx-Class/lib/DBIx/Class/Row.pm
===================================================================
--- trunk/DBIx-Class/lib/DBIx/Class/Row.pm	2007-06-06 21:27:39 UTC (rev 3476)
+++ trunk/DBIx-Class/lib/DBIx/Class/Row.pm	2007-06-07 20:16:34 UTC (rev 3477)
@@ -108,7 +108,8 @@
 
 Also takes an options hashref of C<< column_name => value> pairs >> to update
 first. But be aware that this hashref might be edited in place, so dont rely on
-it being the same after a call to C<update>.
+it being the same after a call to C<update>. If you need to preserve the hashref,
+it is sufficient to pass a shallow copy to C<update>, e.g. ( { %{ $href } } )
 
 =cut
 

Modified: trunk/DBIx-Class/t/68inflate_serialize.t
===================================================================
--- trunk/DBIx-Class/t/68inflate_serialize.t	2007-06-06 21:27:39 UTC (rev 3476)
+++ trunk/DBIx-Class/t/68inflate_serialize.t	2007-06-07 20:16:34 UTC (rev 3477)
@@ -40,43 +40,47 @@
 );
 Class::C3->reinitialize;
 
-my $complex1 = {
-    id => 1,
-    serialized => {
-        a => 1,
-	b => [ 
-	    { c => 2 },
-	],
-        d => 3,
-    },
+my $struct_hash = {
+    a => 1,
+    b => [ 
+        { c => 2 },
+    ],
+    d => 3,
 };
 
-my $complex2 = {
-    id => 1,
-    serialized => [
-		'a', 
-		{ b => 1, c => 2},
-		'd',
-	    ],
-};
+my $struct_array = [
+    'a', 
+    { 
+	b => 1,
+	c => 2
+    },
+    'd',
+];
 
 my $rs = $schema->resultset('Serialized');
-my $entry = $rs->create({ id => 1, serialized => ''});
-
 my $inflated;
 
-ok($entry->update ({ %{$complex1} }), 'hashref deflation ok');
-ok($inflated = $entry->serialized, 'hashref inflation ok');
-is_deeply($inflated, $complex1->{serialized}, 'inflated hash matches original');
+#======= testing hashref serialization
 
-my $entry2 = $rs->create({ id => 2, serialized => ''});
+my $object = $rs->create( { 
+    id => 1,
+    serialized => '',
+} );
+ok($object->update( { serialized => $struct_hash } ), 'hashref deflation');
+ok($inflated = $object->serialized, 'hashref inflation');
+is_deeply($inflated, $struct_hash, 'inflated hash matches original');
 
-eval { $entry2->set_inflated_column('serialized', $complex1->{serialized}) };
+$object = $rs->create( { 
+    id => 2,
+    serialized => '',
+} );
+eval { $object->set_inflated_column('serialized', $struct_hash) };
 ok(!$@, 'set_inflated_column to a hashref');
-$entry2->update;
-is_deeply($entry2->serialized, $complex1->{serialized}, 'inflated hash matches original');
+is_deeply($object->serialized, $struct_hash, 'inflated hash matches original');
 
-ok($entry->update ({ %{$complex2} }), 'arrayref deflation ok');
-ok($inflated = $entry->serialized, 'arrayref inflation ok');
-is_deeply($inflated, $complex2->{serialized}, 'inflated array matches original');
 
+#====== testing arrayref serialization
+
+ok($object->update( { serialized => $struct_array } ), 'arrayref deflation');
+ok($inflated = $object->serialized, 'arrayref inflation');
+is_deeply($inflated, $struct_array, 'inflated array matches original');




More information about the Bast-commits mailing list