[Dbix-class] BUG? Unable to resolve relationship

Peter Rabbitson rabbit+dbic at rabbit.us
Sat Dec 12 10:27:37 GMT 2009


Ovid wrote:

> 
> 
> Also, you stated that "might_have is the LEFT JOIN version of has_many."  The docs say "one-to-one".  Which is correct? 

Rob is wrong - might_have and has_many produce identical SQL. The difference is how the
result is interpreted. has_many is a multi-type accessor, so when you call ->doodads
you get a resultset object from which 0 or more objects can be retrieved. If instead
you use might_have, calling the accessor (which you'll probably call->doodad, instead
of doodads) will either return a *row* object, or undef. If the sql contains more than
1 result, the first one is turned into an object, and the rest of the results is
discarded with a loud warning.



More information about the DBIx-Class mailing list