[Dbix-class] Re: Relations and inflation
Matt Rosin
mattrosin at yahoo.com
Fri Jun 22 16:31:40 GMT 2007
A brief p.s. to the preceding question. (another documentation issue I think).
The Relationship.pm pod says under belongs_to:
Cascading deletes are off by default on a belongs_to relationship. To turn them on, pass cascade_delete => 1 in the $attr hashref.
Now what I want to do is make a coupon get deleted if the listing to which it belongs is deleted.
But I definitely do not ever want the deletion of a coupon to cause a listing to be deleted.
I can't quite tell which direction the deletion is going to go if I turn on cascade_delete in Listing.pm, because the docs are vague.
In CatMgrDB/Listing.pm I have now replaced might_have with belongs_to, so inflation of $listing->coupon now works
__PACKAGE__->belongs_to( coupon => CatMgrDB::Coupon );
So if I change it to:
__PACKAGE__->belongs_to( coupon => CatMgrDB::Coupon, coupon, {cascade_delete => 1} );
will it then cause the coupon to be deleted automatically if a listing is deleted?
And then I should definitely not put the cascade_delete line into Coupon.pm, correct?
Thanks,
Matt
____________________________________________________________________________________
Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/
More information about the Dbix-class
mailing list