Fix lazy loading when the object has been deleted
Michael G Schwern [Wed, 12 Mar 2008 21:29:58 +0000 (21:29 +0000)]
lib/DBIx/Class/CDBICompat/LazyLoading.pm

index e8ffbcc..e07579a 100644 (file)
@@ -103,7 +103,9 @@ sub _flesh {
     #                                   $self->ident_condition);
     # Not sure why the first one works and this doesn't :(
     my @val = $cursor->next;
-#warn "Flesh: ".join(', ', @want, '=>', @val);
+
+    return unless @val; # object must have been deleted from the database
+
     foreach my $w (@want) {
       $self->{'_column_data'}{$w} = shift @val;
     }