From: Michael G Schwern Date: Thu, 13 Mar 2008 18:50:32 +0000 (+0000) Subject: Test lazy loading with a deleted object. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b33ae6a0ac1ea59f45e63ba11010ef7a6947319b;p=dbsrgits%2FDBIx-Class-Historic.git Test lazy loading with a deleted object. --- diff --git a/t/cdbi-t/04-lazy.t b/t/cdbi-t/04-lazy.t index f67201b..7b5a24c 100644 --- a/t/cdbi-t/04-lazy.t +++ b/t/cdbi-t/04-lazy.t @@ -15,7 +15,7 @@ BEGIN { next; } eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 35); + plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 36); } INIT { @@ -155,3 +155,30 @@ SKIP: { $l->delete; } + + +# Test that a deleted object works +{ + Lazy->search()->delete_all; + my $l = Lazy->create({ + this => 99, + that => 2, + oop => 3, + opop => 4, + }); + + # Delete the object without it knowing. + Lazy->db_Main->do(qq[ + DELETE + FROM @{[ Lazy->table ]} + WHERE this = 99 + ]); + + $l->eep; + + # The problem was when an object had an inflated object + # loaded. _flesh() would set _column_data to undef and + # get_column() would think nothing was there. + # I'm too lazy to set up the proper inflation test. + ok !exists $l->{_column_data}{orp}; +}