Hi,<br>
<br>
I am having a problem, in which I couldn't get the relationship column data by using prefetch.<br>
My relationship is declared like this, suppose we have two tables: railway and railway_station, which relationship is 1 to many.<br>
<br>
#in railway schema<br>
__PACKAGE__-&gt;has_many(<br>
&nbsp;&nbsp;&nbsp; "railway_station",<br>
&nbsp;&nbsp;&nbsp; "Schema::RailwayStation",<br>
&nbsp;&nbsp;&nbsp; { "foreign.railway_station_railway_id" =&gt; "self.railway_id" },<br>
);<br>
<br>
#in railway_station schema<br>
__PACKAGE__-&gt;belongs_to(<br>
&nbsp; "railway",<br>
&nbsp; "Schema::Railway",<br>
&nbsp; { "foreign.railway_id" =&gt; "self.railway_station_railway_id" },<br>
);<br>
<br>
My prefetch command is as follows:<br>
<br>
&nbsp;&nbsp; my $railways = $schema-&gt;resultset('Railway')-&gt;search(<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'me.railway_id' =&gt; { 'IN' =&gt; $selected_railway_ids },<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; join =&gt; 'railway_station',<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prefetch =&gt; 'railway_station',<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; );<br>
&nbsp;&nbsp; &nbsp;<br>
I could get the values of the columns of the railways correctly, but not the columns of railway_stations.<br>
If I use 'join' only though, I could get all the data for railways which only have 1 row of railway_station, but not for<br>
railways which have more than 1 rows of railway_station.<br>
Any ideas why this happened ? <br>
I have a hunch that maybe it's the ID of the railway_station that is causing this problem. In our current database, the primary key of<br>
railway_station works as a dummy field, in which there are a lot of null values (although they are primary keys). <br>
Of course, I have my own objections to this current implementation, but I am wondering if that is indeed the problem, since the primary key of railway_station isn't supposed to be used in any query generated above ?<br>
Or maybe I am missing something else here.<br>
<br>
Regards,<br>
<br>
Sindharta<br>
<br>
<br>
<br>
<br>

<div style="line-height: 0; width: 0; height: 5px; clear: both;">&nbsp;</div>
<p>&#32;

<hr size=1><a href=http://pr.mail.yahoo.co.jp/toolbar/ target="new">Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar</a><br>