[Dbix-class] missing 'many-to-many' relationship

fREW Schmidt frioux at gmail.com
Wed Aug 4 17:04:17 GMT 2010


> So to be clear, you are saying that you added the roles many to many in
>> user and you do $user->roles and get that error?
>>
>> I'm guessing you did something like $user->related_resultset('roles'),
>> which wouldn't work since technically m2m isn't a relationship.
>>
>>  That's exactly what I'm doing!  Since I had to get something working I
> took a couple of extra steps,
> and got the functionality I was looking for, but I find myself wondering
> what the benefit of having a
> 'many_to_many' pseudo-relationship is?
>
> Thank you for this explanation, it will keep me sane! :)
>

Yeah, you have to do the extra steps.  For people watching along the reason
comes from DBIx::Class::Relationship:

many_to_many is not strictly a relationship in its own right. Instead, it is
> a bridge between two resultsets which provide the same kind of convenience
> accessors as true relationships provide. Although the accessor will retur=
n a
> resultset or collection of objects just like has_many does, you cannot ca=
ll
> related_resultset and similar methods which operate on true relationships.
>

as for *why* this is done this way, I couldn't say.

Anyone wanna chime in on why m2m isn't a real rel?

-- =

fREW Schmidt
http://blog.afoolishmanifesto.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100804/6be=
1bf57/attachment.htm


More information about the DBIx-Class mailing list