[CDBI] Problem with cascade strategy

Carlos Vicente cvicente at network-services.uoregon.edu
Tue Jul 8 00:54:08 BST 2008

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);
      } $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.


More information about the ClassDBI mailing list