[Dbix-class] RecursiveUpdate and many to many

Matt S Trout dbix-class at trout.me.uk
Sat Sep 27 19:59:20 BST 2008


On Sat, Sep 27, 2008 at 09:54:44AM +0200, Zbigniew Lukasiak wrote:
> Hi Matt,
> 
> I would like to include your critisizm of the support for many to many
> in RecursiveUpdate in it's documentation.  Tell me if I get it right.
> What I remember is two points:
> 
> 1. That I rely on the fact that
> 
> if($object->can($name) and
>             !$object->result_source->has_relationship($name) and
>             $object->can( 'set_' . $name )
>         )
> 
> then $name must be a many to many pseudo relation.  And that in a
> similarly ugly was I find out what is the ResultSource of objects from
> that many to many pseudo relation.
>
> 2. That I treat uniformly relations and many to many (which are
> different from relations because they require traversal of the bridge
> table).
> 
> Is that right?

Precisely, which means your code is fragile and implicitly broken.

If you really want to support such a feature, then you should make it

(a) optional
(b) off by default

since it can't currently be done safely, and anything non-safe in code
that's designed to talk to your production DB is -bad-.

-- 
      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/



More information about the DBIx-Class mailing list