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> my $rs = $c->config->{schema}->resultset('Receptor')->search<br> ({class4 => 'Orphan'},
<br> {prefetch => {natural_ligands_map => 'ligand'}});<br><br> my $count = $rs->count;<br> # $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> my $rs = $c->config->{schema}->resultset('Receptor')->search<br>
({class4 => 'Orphan'});<br>
<br>
my $count = $rs->count;<br>
# $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 ) JOIN natural_ligands ligand ON ( ligand.ligid = natural_ligands_map.ligid ) WHERE ( ( ( class4 = ? ) ) ) ORDER BY natural_ligands_map.gpcrid: `Orphan'
<br><br><br><br>