[Dbix-class] pick and choose columns with join + collapse

Seth Daniel dbix-class at sethdaniel.org
Fri Feb 6 19:08:35 GMT 2015


On Fri, Feb 6, 2015 at 12:29 AM, Peter Rabbitson <rabbit+dbic at rabbit.us>
wrote:

> 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
>

 That was it.  Thank you very much.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20150206/5e686d76/attachment.htm>


More information about the DBIx-Class mailing list