Is this the expected behaviour of prefetch? Apologies for not replacing all the names with 'foo', 'bar' etc.<br><br>Receptor has a 'many to many' relationship with Ligand, with 'natural_ligands_map' being the bridging relationship.
<br><br>I want to preform a search on Receptor which prefetches all the Ligand rows. So I do the following:<br><br>&nbsp;&nbsp;&nbsp; my $rs = $c-&gt;config-&gt;{schema}-&gt;resultset('Receptor')-&gt;search<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ({class4 =&gt; 'Orphan'},
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {prefetch =&gt; {natural_ligands_map =&gt; 'ligand'}});<br><br>&nbsp;&nbsp;&nbsp; my $count = $rs-&gt;count;<br>&nbsp;&nbsp;&nbsp; # $count is 0 here<br><br>The search returned no results despite there being 60 Receptor rows which have a class4 of 'Orphan'. The reason for this is that these receptors don't have any Ligands. Proved by the following :
<br>
<br>&nbsp;&nbsp;&nbsp; my $rs = $c-&gt;config-&gt;{schema}-&gt;resultset('Receptor')-&gt;search<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ({class4 =&gt; 'Orphan'});<br>
<br>
&nbsp; &nbsp; my $count = $rs-&gt;count;<br>
&nbsp; &nbsp; # $count is 60 here<br><br>this returns 60 receptors as expected.<br><br>Now, I want the Receptor rows even if they don't have any Ligands but that doesn't appear to be possible. Is this a bug or is it the expected behaviour? If it's a bug I'll knock up a test case for y'all.
<br><br>Obviously not doing the prefetch solves the problem but in this case that's much too expensive. <br><br>Thanks,<br>Luke.<br><br>Resulting debug SQL from first search for reference (I replaced the column names with * to save space):
<br>SELECT me.*, natural_ligands_map.*, ligand.* FROM receptors me LEFT JOIN natural_ligands_2_receptors natural_ligands_map ON ( natural_ligands_map.gpcrid = me.gpcrid )&nbsp; JOIN natural_ligands ligand ON ( ligand.ligid = natural_ligands_map.ligid ) WHERE ( ( ( class4 = ? ) ) ) ORDER BY natural_ligands_map.gpcrid: `Orphan'
<br><br><br><br>