[Dbix-class] pick and choose columns with join + collapse
Peter Rabbitson
rabbit+dbic at rabbit.us
Fri Feb 6 08:29:37 GMT 2015
On 02/05/2015 09:56 PM, Seth Daniel wrote:
>
> ...
>
>
> my $rs = $s->resultset( 'A' )
> ->search( { 'B.name' => 'some_name' },
> { columns => [ 'id', { 'A_B.B.name => 'B.name' } ],
> collapse => 1,
> join => [ { A_B => 'B' },
> { A_B => 'B' } ] } );
>
> This does return only the columns I ask for, but it also only returns
> the B that match the search criteria instead of all B for the selected A.
Yes - you asked for B.name to be put into A_B.B.name and you also
referenced it in the where condition. What you want is (likely)
columns => [ 'id', { 'A_B.B.name => 'B_2.name' }
Check the generated DBIC_TRACE=1 (and maybe in addition
DBIC_TRACE_PROFILE=console) to easier wrap your head around what is
going on.
Cheers
More information about the DBIx-Class
mailing list