DBICで想定していないdeleteを実行しないパッチ
http://d.hatena.ne.jp/tomyhero/20070717/1184682521
普通に引数のチェックをするだけですが。
Index: ResultSet.pm =================================================================== --- ResultSet.pm (revision 20773) +++ ResultSet.pm (working copy) @@ -1211,7 +1211,8 @@ =cut sub delete { - my ($self) = @_; + my $self = shift; + $self->throw_exception("You Hit the Bug!!") if @_; my $cond = $self->_cond_for_update_delete; @@ -1235,7 +1236,9 @@ =cut sub delete_all { - my ($self) = @_; + my $self = shift; + $self->throw_exception("You Hit the Bug!!") if @_; + $_->delete for $self->all; return 1; }
delete_allはallなんだからいらないかなとかおもたり。
ちなみにrelationの設定でカスケードを切っておかないと
関連テーブルもまとめてdeleteされるのでより死ねます。
(追記)
なので、個人的にはdelete_fgなどのフラグをもって
updateすることをおススメよ!
うちの会社では基本物理削除はせずに論理削除する方針