<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-&gt;resultset( &#39;Track&#39; )-&gt;search( {},<br>        {<br>            join =&gt; { &#39;cd&#39; =&gt; &#39;artist&#39; },<br>            &#39;+select&#39; =&gt; [ &#39;artist.artistid&#39; ],<br>            &#39;+as&#39; =&gt; [ &#39;artistid&#39; ],<br>            alias   =&gt; &#39;track_list_sub_rs&#39;<br>        }<br>    );<br><br>    my $rs = $schema-&gt;resultset(&#39;Artist&#39;)-&gt;search(<br>        { &#39;<a href="http://me.name">me.name</a>&#39; =&gt; &#39;Michael Jackson&#39; },<br>        {<br>            from  =&gt; [<br>                { &#39;me&#39;    =&gt; &#39;artist&#39; },<br>                [<br>                    { &#39;tracklíst&#39; =&gt; $track_list_rs-&gt;as_query },<br>                    { &#39;me.artistid&#39; =&gt; { -ident =&gt; &#39;tracklíst.artistid&#39; } },<br>                ]<br>            ],<br>            &#39;+columns&#39; =&gt; [ qw/ tracklíst.title / ],<br>            collapse =&gt; 1,<br>            result_class    =&gt; &#39;DBIx::Class::ResultClass::HashRefInflator&#39;,<br>        }<br>    );<br><br>    while( my $michael_jackson = $rs-&gt;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> = &#39;Michael Jackson&#39; <br>    ORDER BY me.artistid<br><br>The error message is &quot;No such relationship &#39;tracklíst&#39; on Artist at /usr/local/share/perl/5.18.2/DBIx/Class/Schema.pm line 1081.&quot;.<br><br></div><div>For prefetching the tracklist, I use &#39;+columns&#39; and &#39;collapse&#39;, because I expected those two not to check for the accessor &quot;tracklist&quot; (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">&lt;<a href="mailto:rabbit+dbic@rabbit.us" target="_blank">rabbit+dbic@rabbit.us</a>&gt;</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&#39;m struggling. I thought, I could simply use a sub query in<br>
the from-attribute when searching the resultset and adding &quot;+columns&quot;<br>
and setting &quot;collapse&quot; 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&#39;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&#39;s not clear what you tried from your description alone. Also makes the &quot;this is what I want to get&quot; 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>