AW: [Dbix-class] Complex table joins

FastJack shad0wrunner at gmx.de
Mon May 21 17:35:48 GMT 2007



> -----Ursprüngliche Nachricht-----
> Von: Richard Jones [mailto:ra.jones at dpw.clara.co.uk] 
> Gesendet: Montag, 21. Mai 2007 14:53
> An: dbix-class at lists.rawmode.org
> Betreff: Re: [Dbix-class] Complex table joins
> 
> 
> SHAD0WRUNNER at gmx.de wrote:
> >> Based on the Cookbook 'Multi-step joins' section I've tried various
> >> variations of:
> >>   join => [ qw/table_2 table_3 table_4 table_5/ ],
> >>   join => [ qw/table_2 table_3/], { 'table_4' => 'table_5' } ],
> >>   join => [ qw/table_2 table_3/], table_1 => { 'table_4' 
> => 'table_5' } ],
> >>   etc.
> >>     
> >
> > I think
> >
> > join => [{ 'table_4' => 'table_5' }, qw/table_2 table_3/]
> >
> > should work.
> >   
> No, it doesn't. I know the arrayref generates valid sql as I 
> can extract 
> it from the DBIC::Profiler output and run it manually. It 
> finds the data 
> I want. I have also manually constructed 'from' as a complex data 
> structure (see below),  but always the same error: 
> "DBIx::Class::ResultSet::single(): No such relationship 
> 'speciality' at 
> ...."

"No such relationship" means, you haven't defined the relationship 
in the Schema::Foo-Package with belongs_to or has_many. As far as I know
you can't simply use the table-name in the join-definition.

> 
> speciality is the alias for table_5, as in:
> 
> >from => {
>   { me => 'requests' },
>   [ # various standard left-joins, then: ],
>   [
>     { 'speciality' => 'specialities', -join-type => 'left' },
>     { 'speciality.id' => table_4.speciality_id' }, # 
> 'speciality.id' now 
> foreign key in table_4
>   ],
> }
> 
> I'm retrieving the data as: 
> $c->model('Schema::Foo')->search($search_criteria_href, 
> $select_href)->single # it's a single-record search
> Then: No such relationship 'speciality', etc
>  
> So frustrating!
> 
> -- 
> Richard Jones 
> 
> 
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive: 
> http://www.mail-archive.com/dbix-class@lists.rawmode.org/




More information about the Dbix-class mailing list