<div dir="ltr"><div>Hello Peter,<br><br></div><div>thanks for your comment.<br><br></div><div>When I want to reconstruct my situation with the data structure given in <a href="https://metacpan.org/pod/DBIx::Class::Manual::Example">https://metacpan.org/pod/DBIx::Class::Manual::Example</a> my search call would be ...<br><br> my $track_list_rs = $schema->resultset( 'Track' )->search( {},<br> {<br> join => { 'cd' => 'artist' },<br> '+select' => [ 'artist.artistid' ],<br> '+as' => [ 'artistid' ],<br> alias => 'track_list_sub_rs'<br> }<br> );<br><br> my $rs = $schema->resultset('Artist')->search(<br> { '<a href="http://me.name">me.name</a>' => 'Michael Jackson' },<br> {<br> from => [<br> { 'me' => 'artist' },<br> [<br> { 'tracklíst' => $track_list_rs->as_query },<br> { 'me.artistid' => { -ident => 'tracklíst.artistid' } },<br> ]<br> ],<br> '+columns' => [ qw/ tracklíst.title / ],<br> collapse => 1,<br> result_class => 'DBIx::Class::ResultClass::HashRefInflator',<br> }<br> );<br><br> while( my $michael_jackson = $rs->next ) { # there can be only one...<br> print Dumper( $michael_jackson );<br> }<br><br></div><div>Here I simply want to build a list of tracks per artist and connect it to the artist directly.<br></div><div><br></div><div>It is producing a good sql query string, but fails because of the missing accessor:<br><br> SELECT me.artistid, <a href="http://me.name">me.name</a>, tracklíst.title <br> FROM artist me <br> JOIN ( <br> SELECT track_list_sub_rs.trackid, <a href="http://track_list_sub_rs.cd">track_list_sub_rs.cd</a>, track_list_sub_rs.title, artist.artistid <br> FROM track track_list_sub_rs <br> JOIN cd cd <br> ON cd.cdid = <a href="http://track_list_sub_rs.cd">track_list_sub_rs.cd</a> <br> JOIN artist artist <br> ON artist.artistid = cd.artist<br> ) tracklíst <br> ON me.artistid = tracklíst.artistid <br> WHERE <a href="http://me.name">me.name</a> = 'Michael Jackson' <br> ORDER BY me.artistid<br><br>The error message is "No such relationship 'tracklíst' on Artist at /usr/local/share/perl/5.18.2/DBIx/Class/Schema.pm line 1081.".<br><br></div><div>For prefetching the tracklist, I use '+columns' and 'collapse', because I expected those two not to check for the accessor "tracklist" (but this seemed to be a wrong assumption).<br></div><div><br>Unfortunately I was not able to reconstruct the search call that was providing a result with only a single item out of the sub query results, since I made some changes in the meantime.<br><br></div><div>Best regards<br>Thilo<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-02-12 16:47 GMT+01:00 Peter Rabbitson <span dir="ltr"><<a href="mailto:rabbit+dbic@rabbit.us" target="_blank">rabbit+dbic@rabbit.us</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 02/11/2015 11:13 AM, <a href="mailto:thilo.fester@googlemail.com" target="_blank">thilo.fester@googlemail.com</a> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
At the beginning working around this problem seemed kind of trivial to<br>
me, but now I'm struggling. I thought, I could simply use a sub query in<br>
the from-attribute when searching the resultset and adding "+columns"<br>
and setting "collapse" to a true value. But this way, I am ending up<br>
with only a single property column.<br>
</blockquote>
<br></span>
The short answer is - it's likely possible, or it can be made to work with relatively few extra changes.<br>
<br>
But you need to show the actual search call you constructed, it's not clear what you tried from your description alone. Also makes the "this is what I want to get" example baseless and hard to interpret.<br>
<br>
Cheers<br>
<br>
______________________________<u></u>_________________<br>
List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-<u></u>bin/mailman/listinfo/dbix-<u></u>class</a><br>
IRC: <a href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target="_blank">http://dev.catalyst.perl.org/<u></u>repos/bast/DBIx-Class/</a><br>
Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" target="_blank">http://www.grokbase.com/group/<u></u>dbix-class@lists.scsys.co.uk</a><br>
</blockquote></div><br></div>