[Bast-commits] r5620 - in DBIx-Class/0.08/trunk: lib/DBIx/Class t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Sun Feb 22 12:43:54 GMT 2009


Author: ribasushi
Date: 2009-02-22 12:43:54 +0000 (Sun, 22 Feb 2009)
New Revision: 5620

Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
   DBIx-Class/0.08/trunk/t/66relationship.t
Log:
fix exception on esoteric new_related (by zby)

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm	2009-02-22 03:07:41 UTC (rev 5619)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/ResultSet.pm	2009-02-22 12:43:54 UTC (rev 5620)
@@ -1700,7 +1700,7 @@
     defined $self->{cond}
     && $self->{cond} eq $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION
   ) {
-    %new = %{$self->{attrs}{related_objects}};
+    %new = %{ $self->{attrs}{related_objects} || {} };  # nothing might have been inserted yet
     $new{-from_resultset} = [ keys %new ] if keys %new;
   } else {
     $self->throw_exception(

Modified: DBIx-Class/0.08/trunk/t/66relationship.t
===================================================================
--- DBIx-Class/0.08/trunk/t/66relationship.t	2009-02-22 03:07:41 UTC (rev 5619)
+++ DBIx-Class/0.08/trunk/t/66relationship.t	2009-02-22 12:43:54 UTC (rev 5620)
@@ -8,7 +8,7 @@
 
 my $schema = DBICTest->init_schema();
 
-plan tests => 69;
+plan tests => 70;
 
 # has_a test
 my $cd = $schema->resultset("CD")->find(4);
@@ -138,6 +138,15 @@
 is($newartist->name, 'Random Boy Band Two', 'find_or_new_related new artist record with id');
 is($newartist->id, 200, 'find_or_new_related new artist id set');
 
+lives_ok( 
+    sub { 
+        my $new_bookmark = $schema->resultset("Bookmark")->new_result( {} );
+        my $new_related_link = $new_bookmark->new_related( 'link', {} );
+    },
+    'No back rel'
+);
+
+
 TODO: {
   local $TODO = "relationship checking needs fixing";
   # try to add a bogus relationship using the wrong cols




More information about the Bast-commits mailing list