1 package DBIx::Class::Relationship::CascadeActions;
4 my ($self, @rest) = @_;
5 return $self->NEXT::ACTUAL::delete(@rest) unless ref $self;
6 # I'm just ignoring this for class deletes because hell, the db should
7 # be handling this anyway. Assuming we have joins we probably actually
8 # *could* do them, but I'd rather not.
10 my $ret = $self->NEXT::ACTUAL::delete(@rest);
12 my %rels = %{ $self->_relationships };
13 my @cascade = grep { $rels{$_}{attrs}{cascade_delete} } keys %rels;
14 foreach my $rel (@cascade) {
15 $self->search_related($rel)->delete;
21 my ($self, @rest) = @_;
22 return $self->NEXT::ACTUAL::update(@rest) unless ref $self;
23 # Because update cascades on a class *really* don't make sense!
25 my $ret = $self->NEXT::ACTUAL::update(@rest);
27 my %rels = %{ $self->_relationships };
28 my @cascade = grep { $rels{$_}{attrs}{cascade_update} } keys %rels;
29 foreach my $rel (@cascade) {
30 $_->update for $self->$rel;