On Thu, 19 Apr 2007, Pedro Melo wrote:
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.
DBIC much prefers that you allow/setup the database to do the
delete-cascading, if it deleted the related objects first, and then the
main one, then DB-side would never kick in. Also if the DB rels had ON
CASCADE FAIL set, we'd never trigger it.
The DBIC-side cascade is merely to paper over the cracks of databases that
don't support DB-side FK setting and so on.
Jess
_______________________________________________
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]/