<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 17, 2014 at 7:39 PM, John Stoffel <span dir="ltr"><<a href="mailto:john@stoffel.org" target="_blank">john@stoffel.org</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi all,<br>
<br>
With a bit of nudging, I had a head-smack moment and upgraded to the<br>
latest version of DBIx::Class on CPAN, and it now looks like things<br>
are working better for me, but I'm still getting some interesting<br>
behavior.<br>
<br>
Before I got errors, now I can do:<br>
<br>
> ../bin/<a href="http://dbic-test.pl" target="_blank">dbic-test.pl</a> Emlen<br>
DBIx::Class::ResultSet::_construct_results(): Unable to properly collapse has_many results in iterator mode due to order criteria - performed an eager cursor slurp underneath. Consider using ->all() instead at ../bin/<a href="http://dbic-test.pl" target="_blank">dbic-test.pl</a> line 20<br></blockquote><div><br></div><div>Do you have proper non-nullable primary keys set up in all the relevant result classes?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""> Full Name: Emlen & Howell (8213)<br>
</span> account_id=5920 boxfolder_id=234 URL: b16f10<br>
account_id=5921 boxfolder_id=249 URL: b17f10<br>
account_id=5922 boxfolder_id=281 URL: b19f12<br>
Full Name: Emlen, Caleb (8214)<br>
account_id=5923 boxfolder_id=14 URL: b01f14<br>
account_id=5924 boxfolder_id=50 URL: b04f05<br>
<br>
<br>
So I think I need to change my loop from:<br>
<span class=""><br>
while (my $r = $rs->next) {<br>
print "Full Name: ", $r->full_name, " (", $r->name_id, ")\n";<br>
<br>
foreach my $a ($r->account()) {<br>
</span> print " account_id=", $a->account_id();<br>
print " boxfolder_id=",$a->boxfolder_id()," ";<br>
<span class=""> my $t = $a->url();<br>
$t =~ m/value2=(\w+)\&/;<br>
</span> print " URL: $1";<br>
$vol = $a->boxfolder->volume;<br>
$folder = $a->boxfolder->volume;<br>
$range = $a->boxfolder->range;<br>
print " V=$vol " if defined $vol;<br>
print " F=$folder " if defined $folder;<br>
print " R=$range " if defined $range;<br>
<br>
print "\n";<br>
}<br>
}<br>
<br>
<br>
To something more like this:<br>
<br>
my @r = $rs->all<br>
foreach my $r (@r) {<br>
<span class=""></span></blockquote><div><br></div><div>Be aware that this will cost you in terms of memory because you'll inflate all row objects once. Especially if you prefetch a lot... Depending on your specific result sets, this may not matter to you... But it's definitely something to be aware of...</div><div><br></div><div>We've seen lots of worker processes gobble up 50 - 100 MB of extra memory because of this, so we've been converting most uses of foreach my $row ($rs->all) { ... } to while (my $row = $rs->next) { ... }. YMMV.</div><div><br></div><div>/L</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""> print "Full Name: ", $r->full_name, " (", $r->name_id, ")\n";<br>
<br>
foreach my $a ($r->account()) {<br>
</span> print " account_id=", $a->account_id();<br>
print " boxfolder_id=",$a->boxfolder_id()," ";<br>
<span class=""> my $t = $a->url();<br>
$t =~ m/value2=(\w+)\&/;<br>
</span> print " URL: $1";<br>
$vol = $a->boxfolder->volume;<br>
$folder = $a->boxfolder->volume;<br>
$range = $a->boxfolder->range;<br>
print " V=$vol " if defined $vol;<br>
print " F=$folder " if defined $folder;<br>
print " R=$range " if defined $range;<br>
<br>
print "\n";<br>
}<br>
}<br>
<br>
And that does seem to do the trick. Now to move onto updating my<br>
Dancer web interface and see if I'm getting proper data out (or that I<br>
even have proper data IN!) of the DB and displayed nicely for the end<br>
users.<br>
<br>
Thanks for the help, I feel a little dumb for not thinking to upgrade right off the bat.<br>
<br>
Cheers,<br>
John<br>
<div class="HOEnZb"><div class="h5"><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>
</div></div></blockquote></div></div></div>