[Dbix-class] in_storage and cascade delete

Matt S Trout dbix-class at trout.me.uk
Thu Mar 16 14:19:41 CET 2006


Richard Jolly wrote:
> Hi,
> 
> $obj->in_storage is not correct if the object has been deleted by a 
> cascade delete. Is that a problem? I'm not sure how you could guarantee 
> that in_storage is always correct, baring doing a find().
> 
> # Foo has_many Bars
> 
> $f = $schema->resultset('Foo')->create(...);
> $b = $schema->resultset('Bar')->create(...);
> 
> $b->foo( $f );
> $b->update;
> 
> $f->delete;
> 
> $schema->resultset('Foo')->count; # 0
> $schema->resultset('Bar')->count; # 0
> 
> $b->in_storage; # 1

It's a result of the design. I figured the user having to think about this and
deal with it was better than getting into the LiveObjectIndex can of worms.

Note that if you want to be sure an object is fresh, calling

$o->discard_changes

*will* re-SELECT the object, and clear in_storage if it isn't found.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list