On Tue, Sep 11, 2007 at 10:20:50PM -0700, Dustin Suchter wrote: > Well, I found a solution to my problem. I'm not sure it is the most > elegant, but here goes: > > I figured that just putting the proper cascade logic into my actual > DB schema would fix things, and it does. I changed my table > definition to: > > I think a better solution (TIMTOWTDI) is to for DBIx to somehow > automatically detect the constraint and transact a delete that > removes the child rows first and then the parent rows, in order to > make sure everything gets deleted. I think that one is a pipe dream > so I'll happily use my solution above for now.
Couple of notes: (1) it's DBIx::Class, DBIx:: is the namespace for -all- DBI extensions (2) it has its own mailing list As for automatically detecting the constraint, if you use $schema->deploy to let DBIC generate your CREATE TABLE statements for you it puts in the constraint cascades automatically so you'll never see a problem. We intentionally don't override cascade/fk settings on your database to avoid buggy code causing mass dataloss (I've seen this many times before now with ORMs that try to be helpful the way you're requesting) - DBIC -will- try the delete -after- deleting the main record for DBs like SQLite without FKs, but in the case where your database has constraints DBIx::Class prefers to respect them. Either do the cascade clearly in your own code or make sure your DB schema's correct - at least that way when a cascade wipes out a load of data it's easy for the maintenance programmer to see why and how it's happened :) -- 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.shadowcat.co.uk/ _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/