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

Felix Antonius Wilhelm Ostmann ostmann at websuche.de
Wed Dec 15 15:56:45 GMT 2010


Test
$user->groups->search_related('applications', {...});
or
$user->related_resultset('groups')->related_resultset('applications')->...

Am 15.12.2010 16:18, schrieb Jean-François Stenuit:
> 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
> 
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
> 


-- 
Mit freundlichen Grüßen

Felix Antonius Wilhelm Ostmann
-----------------------------------------------------------
Websuche Search Technology GmbH & Co. KG
Martinistraße 3, D-49080 Osnabrück, Germany
-----------------------------------------------------------
Tel.: +49 541 40666-0, Fax: +49 541 40666-22
Email: info at websuche.de, Web: www.websuche.de
-----------------------------------------------------------
AG Osnabrück - HRA 200252, Ust-IdNr.: DE814737310
-----------------------------------------------------------
Komplementärin: Websuche Search Technology Verwaltungs GmbH
AG Osnabrück - HRB 200359, Geschäftsführer: Ansas Meyer
-----------------------------------------------------------



More information about the DBIx-Class mailing list