[CDBI] Problem with cascade strategy
Carlos Vicente <cvicente-zZ82ZiX1S8l+u43qRgrggVnYRNhDb3e+9nwVQlTi/[email protected]> Mon, 07 Jul 2008 16:54:08 -0700
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
Hopefully someone can help me figure out what is going on here. I have
a self-referencing table:
use base 'Netdot::Model';
use Class::DBI::AbstractSearch;
__PACKAGE__->table( 'interface' );
__PACKAGE__->columns( Primary => qw / id /);
__PACKAGE__->has_a( neighbor => 'Netdot::Model::Interface' );
__PACKAGE__->has_many( 'neighbors', 'Netdot::Model::Interface' =>
'neighbor', {cascade=>'Class::DBI::Cascade::Nullify'} );
And my own cascade nullify package has:
use strict;
use warnings;
use base 'Class::DBI::Cascade::None';
sub cascade {
my ($self, $obj) = @_;
map { $_->set($self->{_rel}->args->{foreign_key}, 0);
$_->update
} $self->foreign_for($obj);
}
The problem is that the action does not happen when deleting Interface
objects that have this relationship (it works OK with all other has_many
relationships where I use the same strategy).
Any ideas? Your help is very very much appreciated.
Carlos.