1 package # hide from PAUSE
2 DBIx::Class::Relationship::CascadeActions;
5 my ($self, @rest) = @_;
6 return $self->next::method(@rest) unless ref $self;
7 # I'm just ignoring this for class deletes because hell, the db should
8 # be handling this anyway. Assuming we have joins we probably actually
9 # *could* do them, but I'd rather not.
11 my $ret = $self->next::method(@rest);
13 my $source = $self->result_source;
14 my %rels = map { $_ => $source->relationship_info($_) } $source->relationships;
15 my @cascade = grep { $rels{$_}{attrs}{cascade_delete} } keys %rels;
16 foreach my $rel (@cascade) {
17 $self->search_related($rel)->delete;
23 my ($self, @rest) = @_;
24 return $self->next::method(@rest) unless ref $self;
25 # Because update cascades on a class *really* don't make sense!
27 my $ret = $self->next::method(@rest);
29 my $source = $self->result_source;
30 my %rels = map { $_ => $source->relationship_info($_) } $source->relationships;
31 my @cascade = grep { $rels{$_}{attrs}{cascade_update} } keys %rels;
32 foreach my $rel (@cascade) {
33 $_->update for $self->$rel;