[Dbix-class] Order of operations in CascadeActions::delete

Pedro Melo melo at simplicidade.org
Thu Apr 19 18:19:30 GMT 2007


Hi,

looking at CascadeActions::delete (http://search.cpan.org/src/ 
JROBINSON/DBIx-Class-0.07999_02/lib/DBIx/Class/Relationship/ 
CascadeActions.pm), the code deletes $self and then goes on to delete  
the related objects. Shouldn't this be the reverse?

If a database has FOREIGN KEYs statements with ON DELETE CASCADE, the  
second part will never find any elements to delete. Also, even if we  
don't have ON DELETE CASCADE at the database level, it makes more  
sense to me to first delete the related objects and only then delete  
the "parent" object.

Maybe there is a reason to be like this?

Thanks in advance,
-- 
Pedro Melo
Blog: http://www.simplicidade.org/notes/
Jabber ID: melo at simplicidade.org
Use Jabber!





More information about the Dbix-class mailing list