[Dbix-class] Cascade deletes
Bill Moseley
moseley at hank.org
Wed Mar 10 15:53:58 GMT 2010
On Wed, Mar 10, 2010 at 7:10 AM, Pedro Melo <melo at simplicidade.org> wrote:
> Hi,
>
> On Wed, Mar 10, 2010 at 2:37 PM, Bill Moseley <moseley at hank.org> wrote:
> >> On Tue, Mar 9, 2010 at 11:23 PM, Pedro Melo <melo at simplicidade.org>
> wrote:
> >> for ( qw/ cascade_delete cascade_copy / ) {
> >> # Any user-defined value wins
> >> $options->{$_} =3D 0 unless exists $options->{$_};
> >> }
> >
> > I figured I only needed to set it to zero if $options->{$_} was true, b=
ut
> I
> > guess it's supposed to be zero, not just false.
>
> The reason I coded it this way was to allow a specific relation to set
> cascade_delete =3D> 1. My code defaults to cascade_delete =3D> 0 but
> allows cascade_delete =3D> 1, but your version seems to force
> cascade_delete =3D> 0 in all cases. So it really depends on what you
> actually want.
>
Oh, "*unless* exists". Sorry, I assumed you used "if exists". I'm not sure
"unless exists" works because doesn't DBIC add cascade_delete =3D 1 by defa=
ult
to all relationships that can do cascade_delete even if not explicitly set?
That is, cascade_delete key always exists even when not explicitly set on a
relationship.
My thinking was "if there's a true value for cascade_delete then this is a
relationship that takes "cascade_delete" as a parameter and thus I want to
disable it."
I figured if I needed to turn it back on just for some relationships I'd
have to add something like "really_cascade_delete =3D> 1" and then look for
that in the options hash.
-- =
Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100310/d1c=
3f868/attachment.htm
More information about the DBIx-Class
mailing list