<div dir="ltr">Forgive me if I am misinformed on this issue but this discussion seems to illustrate some of the confusion I have had in following DBIC with less than desired success. <div><br></div><div>The problem here seems to have nothing to do with rows and resultsets but with the implementation on the part of the programmer. </div><div><br></div><div>After using the criteria ddref.idref = 28 he joins that with a dduser table and gets a resultset (not, notably a result) and wants update the column id_credit in the ddref table. But this has nothing to do with the dduser table and regardless of what corresponding rows are in that table the programmer has expressed his intention of updating all of the rows in the ddref table with that idref. So there is no need to make the join to complete the action and the module has done exactly what it was asked to do. If the programmer wanted to update the table based on the join he would need to put in some criteria relating to the joined table, which of course Peter does provide in his example.</div><div><br></div><div>If my understanding is correct the update statement listed would not have &quot;failed&quot; but simply done exactly what was asked of it. ... Unless you were perhaps looking for an inner join - (<span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px">WHERE ddrefs.iduser = dduser.iduser) - </span>which the module could have done but wasn&#39;t really clearly indicated.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 19 November 2014 09:26, Lasse Makholm <span dir="ltr">&lt;<a href="mailto:lasse@unity3d.com" target="_blank">lasse@unity3d.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, Nov 18, 2014 at 12:50 PM, Peter Rabbitson <span dir="ltr">&lt;<a href="mailto:rabbit+dbic@rabbit.us" target="_blank">rabbit+dbic@rabbit.us</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 11/18/2014 12:36 PM, RAPPAZ Francois wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks for replying !<br>
<br>
So it&#39;s a feature, not a bug ?<br>
</blockquote>
<br></span>
It&#39;s neither, it has to do with design.<span><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In mysql, I can execute<br>
&quot;update `ddrefs` inner join `ddusers` using (iduser) set id_credit = 22 WHERE ddrefs.iduser = 3&quot;<br>
</blockquote>
<br></span>
A similar (though *not* identical) effect can be achieved by operating on a ResultSet (not Result). Given your original example, the above would look something like:<br>
<br>
$s-&gt;resultset(&#39;Ddref&#39;)-&gt;<u></u>search(<br>
  { &#39;RefUser.iduser&#39; =&gt; 3 },<br>
  { join =&gt; &#39;RefUser&#39; }<br>
)-&gt;update({ id_credit =&gt; 22 });<br>
<br>
Again - you need to internalize the difference between the Result and ResultSet concepts, they are not interchangeable (if anything - they are orthogonal).</blockquote><div><br></div></span><div>What really made it &quot;click&quot; for me was realizing that I should think of a ResultSet, not primarily as a collection of rows, but rather as an SQL query under construction (that might eventually get executed by calling -&gt;first, -&gt;next, -&gt;all, etc...).</div><div><br></div><div>In reality, of course, ResultSets behave as both, but the part about it being a query-in-the-making is a subtle yet profound aspect that enables all sorts of interesting design patterns.</div><div><br></div><div>It took me too long to realize this when I started out with DBIC - probably because our code base made almost no use of it...</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>/L</div></font></span><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<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>
</div></div></blockquote></span></div><br></div></div>
<br>_______________________________________________<br>
List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-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/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/dbix-class@lists.scsys.co.uk</a><br></blockquote></div><br></div>