Kept getting this error trying to update an object:

Can't call method "update" on an undefined value at 
/usr/local/share/perl/5.8.8/DBIx/Class/Relationship/CascadeActions.pm 
line 36.

In this case the relationship is defined as 'might_have' and for 
this object, it doesn't have one.

This solves the problem:

--- /tmp/CascadeActions.pm      2006-04-07 16:15:25.000000000 -0700
+++ /usr/local/share/perl/5.8.8/DBIx/Class/Relationship/CascadeActions.pm      
2006-04-07 16:15:30.000000000 -0700
@@ -33,7 +33,7 @@
   my %rels = map { $_ => $source->relationship_info($_) } 
$source->relationships;
   my @cascade = grep { $rels{$_}{attrs}{cascade_update} } keys %rels;
   foreach my $rel (@cascade) {
-    $_->update for grep {$_} $self->$rel;
+    $_->update for $self->$rel;
   }
   return $ret;
 }


Sorry if I got that backwards, I can never seem to remember.


--- /tmp/CascadeActions.pm      2006-04-07 16:12:06.000000000 -0700
+++ /usr/local/share/perl/5.8.8/DBIx/Class/Relationship/CascadeActions.pm      
2006-04-07 16:15:02.000000000 -0700
@@ -33,7 +33,7 @@
   my %rels = map { $_ => $source->relationship_info($_) } 
$source->relationships;
   my @cascade = grep { $rels{$_}{attrs}{cascade_update} } keys %rels;
   foreach my $rel (@cascade) {
-    $_->update for $self->$rel;
+    $_->update for grep {$_} $self->$rel;
   }
   return $ret;
 }


Mark



_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/

Reply via email to