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/ 

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to