On Tue, Apr 21, 2009 at 01:48:19AM -0700, Ovid wrote:
>
> Hi all,
>
> I need to be able to globally set these attributes on on those resultsource
> methods which accept them:
>
> {
> cascade_delete => 0,
> cascade_update => 0,
> }
>
>
> It seems like this is being handled on a method by method basis (see
> &DBIx::Class::Relationship::HasOne::_has_one for an example), but the code is
> dense enough (or I am) that I'm not seeing if there is some simple way of
> overriding this behavior. Right now we're hardcoding this for every single
> has_one, has_many, belongs_to, etc., and this is leading to unecessary code
> bloat (and in one case, a bug where a developer forgot to explicitly add
> this). I know how to override this in our base class, but if there's is an
> "official" way of handling this, it would be nice to see.
you should be able to override just add_relationship. Something like -
my %force = map ($_ => 0), qw(cascade_update cascade_delete);
sub add_relationship {
my ($self, $name, $foreign, $join, $attrs) = @_;
$self->next::method($name, $foreign, $join, { %$attrs, %force });
}
A cookbook entry or similar for this would be much appreciated.
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
_______________________________________________
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]