On Sat, Mar 6, 2010 at 1:24 AM, Pedro Melo <[email protected]> wrote:

>  > First, is there a way to globally disable cascade deletes?
>
> I did that once for exactly the same reasons. Created a DBIC component
> that overrides add_relationship(). The fourth parameter is the hashref
> with the options, set cascade_delete => 0 and call the next method.
>

I just added this to my Result base class.  Look similar to what you are
doing?  True, a component is probably a better long-term solution.

sub add_relationship {
    my ( $self, @rest ) = @_;

    my $options = $rest[3];
    if ( ref $options eq 'HASH' ) {
        for ( qw/ cascade_delete cascade_copy / ) {
            $options->{$_} = 0 if $options->{$_};
        }
    }

    return $self->next::method( @rest );
}

(Seems like it would be a rare case where cascade_copy would be desired.)







-- 
Bill Moseley
[email protected]
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to