[Dbix-class] Disable cascading delete, but then...?

2011-06-12 Thread Jesse Sheidlower

I'm working on a new app, where I have a main table called word,
that belongs_to some other tables, including status.

While testing a proof-of-concept version of this app, a colleague made
the obvious discovery that if you delete a status, you'll also
(cascadingly) delete all the words having that status. This is bad.
However, if I just set cascade_delete = 0 for the relationship,
deleting the status will result in these words having a status_id column
that points to a nonexistent row.

Are there standard ways of dealing with this automatically, so that, for
example, deleting the status will instead set the status_id column of
all related words to NULL? Or what else are the usual solutions?

Jesse Sheidlower

___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


Re: [Dbix-class] Disable cascading delete, but then...?

2011-06-12 Thread Bill Moseley
On Sun, Jun 12, 2011 at 3:53 AM, Jesse Sheidlower jes...@panix.com wrote:

 Are there standard ways of dealing with this automatically, so that, for
 example, deleting the status will instead set the status_id column of
 all related words to NULL? Or what else are the usual solutions?


Something like this for your DB?

 status_id  integer REFERENCES status ON DELETE SET NULL

But does it make sense to allow nulls?  Seems like you would want to prevent
a status from being deleted if it's still in use.

-- 
Bill Moseley
mose...@hank.org
___
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk