DBIx::Class の has_many と DELETE

twitterでつぶやくには長いので、ここで書いてみるテストです。

DBIx::Class はリレーションシップ has_many をつけておけば、ブログで言えばあるエントリを削除するときは $schema->delete() するだけで、それへのコメントやタグも削除できるのね。なるほど。
今ちょうどそういうことしようとしてたので便利だなと。


もしこの連動削除をOFFりたい時は、以下をやればいいというわけか。
http://search.cpan.org/~frew/DBIx-Class-0.08121/lib/DBIx/Class/Relationship.pm#has_many

If you delete an object in a class with a has_many relationship, all the related objects will be deleted as well. To turn this behaviour off, pass cascade_delete => 0 in the $attr hashref.