[Dbix-class] Difference between belongs_to and has_one
Matt S Trout
dbix-class at trout.me.uk
Fri Oct 20 22:32:30 CEST 2006
Drew Taylor wrote:
> One thing I discovered after my post which I think is CRITICAL:
> has_one & might_have both use the PK of the local (what's the proper
> terminology?) table as the FK into the foreign table. Perhaps saying
> something like this for the might_have docs:
>
> "Creates an optional one-to-one relationship with a class, where the
> primary key of the foreign class is equal to the primary key of the
> local table. Ie. Foo.id == Bar.id. Unlike belongs_to, might_have ONLY
> suppports using each tables primary key as the key column."
Erm, except that's not true.
That's what they use for the *default* when they're guessing the join
condition for you, as documented. If you pass an explicit join condition, they
do whatever you tell them to.
So clearly an improvement to the docs is "CRITICAL", since even after using it
you still think it does something different to what it actually does :) maybe
you could work on a patch in that direction?
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Dbix-class
mailing list