[Dbix-class] Can't get delete overloaded

Matt S Trout dbix-class at trout.me.uk
Tue Jul 3 21:12:42 GMT 2007


On Tue, Jul 03, 2007 at 07:31:11PM +0200, Eduard Giménez wrote:
> Hello, I've developed a small component that overloads the delete function
> to protect against deleting a referred row.
>  
> On the scheme objects I'm using it like that:
>  
> __PACKAGE__->load_components(qw/ProtectRelationships PK::Auto Core/);
> __PACKAGE__->protect_relationship("my_relationship");
> 
> 
> On the recordsets when I call delete_all it uses the
> ProtectRelationships::delete as expected, but if I call directly delete the
> DBIx::Class:ResultSet::delete will be used.

Right. ->delete does a single delete statement so it doesn't go via class
based stuff at all. You'll need to overload related_resultset to return a
resultset of an appropriate subclass with ->delete overloaded there as
well.

Or you could just use foreign keys and let your DB throw the error for you :)

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 



More information about the Dbix-class mailing list