Created
June 11, 2018 09:42
-
-
Save ribasushi/06257eef7fbc5ba1b980385dd90c3f6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In your base Result class ( ...::Schema::BaseResult ) | |
sub add_relationship { | |
my $self = shift; | |
my $opts = $_[3] || {}; | |
# shut off all DBIC/perl-side cascading logic | |
$opts->{cascade_delete} = 0; | |
$opts->{cascade_update} = 0; | |
$opts->{cascade_copy} = 0; | |
# set reasonable defaults for all FK rels for ->deploy() / ->deployment_statements() purposes | |
if( | |
ref($_[2]) ne 'CODE' | |
and | |
( | |
$opts->{is_foreign_key_constraint} | |
or | |
( | |
! defined ( $opts->{is_foreign_key_constraint} ) | |
and | |
$opts->{is_depends_on} | |
) | |
) | |
) { | |
$opts->{on_update} ||= 'CASCADE'; | |
$opts->{on_delete} ||= 'CASCADE'; | |
} | |
$self->next::method(@_[0..2], $opts); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment