[Dbix-class] Chaining multiple many-to-many relations

Jean-François Stenuit jfs at chryseis.be
Wed Dec 15 15:18:13 GMT 2010


Hi DBIC experts,

Maybe a dumb question, maybe I'm doing it wrong, but I don't seem to
be able to chain two many-to-many relations.

I'm re-writing (OO style) a RBAC system, where a user is part of a
group, and each group has access to a set of applications :

user ----many-to-many---- group ----many-to-many----- application

I'd like to use a shortcut of the form :
my $rsApplications=$rowUser->groups->applications

But it does not seem to work. I get this error :  Can't locate object
method "applications" via package "DBIx::Class::ResultSet"

Addressing the two many-to-many relationships independently works correctly.

Is it at all possible to chain many-to-many relationships ?
DBIx::Class::Relationship doc has some hint about that "you cannot
call related_resultset and similar methods", so I suspect the answer
is negative. But I could be wrong.

Another option would be to create a many-to-many relationship that
spawns all five tables ?

Any hint welcome. Thanks in advance,


Jean-François "Jef" Stenuit



More information about the DBIx-Class mailing list