Remove Class::Data::Inheritable and use CAG 'inherited' style accessors
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / LazyLoading.pm
index e8ffbcc..a9e41af 100644 (file)
@@ -4,6 +4,8 @@ package # hide from PAUSE
 use strict;
 use warnings;
 
+use base 'DBIx::Class';
+
 sub resultset_instance {
   my $self = shift;
   my $rs = $self->next::method(@_);
@@ -12,16 +14,16 @@ sub resultset_instance {
 }
 
 
-# Emulate that CDBI throws out all changed columns and reloads them on 
+# Emulate that CDBI throws out all changed columns and reloads them on
 # request in case the database modifies the new value (say, via a trigger)
 sub update {
     my $self = shift;
-    
+
     my @dirty_columns = keys %{$self->{_dirty_columns}};
-    
+
     my $ret = $self->next::method(@_);
     $self->_clear_column_data(@dirty_columns);
-    
+
     return $ret;
 }
 
@@ -30,12 +32,12 @@ sub update {
 sub create {
     my $class = shift;
     my($data) = @_;
-    
+
     my @columns = keys %$data;
-    
+
     my $obj = $class->next::method(@_);
     return $obj unless defined $obj;
-    
+
     my %primary_cols = map { $_ => 1 } $class->primary_columns;
     my @data_cols = grep !$primary_cols{$_}, @columns;
     $obj->_clear_column_data(@data_cols);
@@ -46,7 +48,7 @@ sub create {
 
 sub _clear_column_data {
     my $self = shift;
-    
+
     delete $self->{_column_data}{$_}     for @_;
     delete $self->{_inflated_column}{$_} for @_;
 }
@@ -71,7 +73,7 @@ sub copy {
   for my $col ($self->primary_columns) {
     $changes->{$col} = undef unless exists $changes->{$col};
   }
-  
+
   return $self->next::method($changes);
 }
 
@@ -103,7 +105,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;
     }