<div dir="ltr"><div><div><div><div><div>I have two tables with a many-to-many relationship, say:<br><br></div>Table A A_B (Join Table) Table B<br><br></div>Any
A can have many B, and any B can be assigned to any A. All via the
join table. Each of A and B has an 'id' and 'name' column (and likely
many other columns that are unimportant for this example). <br><br></div>If
I want to find all A that have any one B assigned to it *and* retrieve
all B for the selected A *and* do this in one query I've been doing
this:<br><br>my $rs = $s->resultset( 'A' ) <br> ->search( { 'B.name' => 'some_name' },<br> { prefetch => [ { A_B => 'B' },<br> { A_B => 'B' } ] } );<br><br></div>I
list the prefetch twice. If I only list it once I only get those B that
match the search criteria, instead of all B for the selected A.<br><br></div>I now want to do the same thing, but only return those columns from A and B that I want. So I tried this:<br><br>my $rs = $s->resultset( 'A' ) <br><div> ->search( { 'B.name' => 'some_name' },<br> { columns => [ 'id', { '<a href="http://A_B.B.name" target="_blank">A_B.B.name</a>' => 'B.name' } ],<br> collapse => 1,<br> join => [ { A_B => 'B' },<br> { A_B => 'B' } ] } );<br><br></div><div>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. <br></div><div><br></div><div>Is there a way I can get the same results as my first example, but by only returning the columns like from my second example?<br></div><div><br></div><div>I've been using DBIx::Class 0.082810. <br><br></div>Thank you.</div>