From: Daniel Ruoso Date: Sun, 13 Jun 2010 21:50:22 +0000 (-0300) Subject: cascades default to 0 when using extended rels X-Git-Tag: v0.08190~1^2~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=edcecdbbc22b3b819dfab5ac62ff65fd5cf6d9d1;p=dbsrgits%2FDBIx-Class.git cascades default to 0 when using extended rels --- diff --git a/BRANCH b/BRANCH index 44f65d6..a462b18 100644 --- a/BRANCH +++ b/BRANCH @@ -80,3 +80,7 @@ What needs to be adjusted (non-exhaustive summary): and multiple codepaths expect _resolve_condition to always return something akin to $vals_from_related above. A grep for _resolve_condition will highlight the problematic use-cases + +Additional Note: + +When using extended_rels all cascade options default to 0. diff --git a/lib/DBIx/Class/Relationship/HasMany.pm b/lib/DBIx/Class/Relationship/HasMany.pm index 21e637d..b8a9b4c 100644 --- a/lib/DBIx/Class/Relationship/HasMany.pm +++ b/lib/DBIx/Class/Relationship/HasMany.pm @@ -49,11 +49,13 @@ sub has_many { $cond = { "foreign.${f_key}" => "self.${pri}" }; } + my $default_cascade = ref $cond eq 'CODE' ? 0 : 1; + $class->add_relationship($rel, $f_class, $cond, { accessor => 'multi', join_type => 'LEFT', - cascade_delete => 1, - cascade_copy => 1, + cascade_delete => $default_cascade, + cascade_copy => $default_cascade, %{$attrs||{}} }); } diff --git a/lib/DBIx/Class/Relationship/HasOne.pm b/lib/DBIx/Class/Relationship/HasOne.pm index 3f1160d..c37f5bf 100644 --- a/lib/DBIx/Class/Relationship/HasOne.pm +++ b/lib/DBIx/Class/Relationship/HasOne.pm @@ -50,10 +50,14 @@ sub _has_one { $cond = { "foreign.${f_key}" => "self.${pri}" }; } $class->_validate_has_one_condition($cond); + + my $default_cascade = ref $cond eq 'CODE' ? 0 : 1; + $class->add_relationship($rel, $f_class, $cond, { accessor => 'single', - cascade_update => 1, cascade_delete => 1, + cascade_update => $default_cascade, + cascade_delete => $default_cascade, ($join_type ? ('join_type' => $join_type) : ()), %{$attrs || {}} }); 1;