[Dbix-class] problem with 'delete'

Matt Lawrence matt.lawrence at ymogen.net
Mon Jan 14 10:07:30 GMT 2008


Angel Kolev wrote:
> package AppModelDB::AppModel;
> use base qw/DBIx::Class/; __PACKAGE__->belongs_to(archive =>
> 'AppModelDB::Schedules', 'id',, {join_type => 'left'}); <snip>
>
>
>
> package AppModelDB::Schedules;
> use base qw/DBIx::Class/; __PACKAGE__->has_many(model =>
> 'AppModelDB::AppModel', 'id');  <snip>
>
> In my script:
> $c->model('AppModelDB::Schedule')->find({id=>184})->delete;  
> This delete id 184 in AppModelDB::AppModel table too. Why? I dont use
> delete_all.
>
find() returns a row, not a resultset. The delete method in
DBIx::Class::Row always cascades. I think that replacing find with
search here will give you your desired behaviour. If you never want
cascading deletions on that relationship, add { cascade_delete => 0 } as
a fourth argument to has_many.


Matt




More information about the DBIx-Class mailing list