Hello,<br><br>I have been using Jifty, along with many other frameworks, and one issue I have had with Jifty was forgetting to use unlimit on a collection that had no conditions. I imagine that there are many Jifty newbies like me with the same frustrations starting out, so I made some warnings:<br>
<br>Let&#39;s say I bless a MyApp::Model::PersonCollection, then I try to loop through -&gt;next iterations without unlimiting, the loop will not even occur.<br>@{ MyApp::Model::PersonCollection } will just be an empty array (though I think _is_limited(-1) should be called if no limit has been set anyway since that&#39;s almost 100% what the user intended in the first place...)<br>
<br>For now, I placed a bunch of warnings where (to my knowledge) the mistake would be made.<br><br>Warnings in `jifty server`:<br>INFO - You can connect to your server at <a href="http://localhost:8888/">http://localhost:8888/</a><br>
INFO - GET request for /<br>WARN - You may have wanted to use -&gt;limit or -&gt;unlimit on the collection at /home/jasonmay/code/perl/jifty/MyApp/lib/MyApp/View.pm line 14<br><br>Warnings in `jifty repl`:<br>jasonmay@culex $ jifty repl<br>
$ @{ MyApp::Model::PersonCollection-&gt;new }<br>WARN - You may have wanted to use -&gt;limit or -&gt;unlimit on the collection at (eval 578) line 5<br>$<br><br>The patch:<br>Index: lib/Jifty/DBI/Collection.pm<br>===================================================================<br>
--- lib/Jifty/DBI/Collection.pm (revision 5218)<br>+++ lib/Jifty/DBI/Collection.pm (working copy)<br>@@ -904,7 +904,10 @@<br>&nbsp;sub peek {<br>&nbsp;&nbsp;&nbsp;&nbsp; my $self = shift;<br>&nbsp;<br>-&nbsp;&nbsp;&nbsp; return (undef) unless ( $self-&gt;_is_limited );<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unless ( $self-&gt;_is_limited ) {<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Carp::carp &quot;You may have wanted to use -&gt;limit or -&gt;unlimit on the collection&quot;;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (undef);<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; $self-&gt;_do_search() if $self-&gt;{&#39;must_redo_search&#39;};<br>
&nbsp;<br>@@ -985,7 +988,10 @@<br>&nbsp;&nbsp;&nbsp;&nbsp; my $self = shift;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; # If we&#39;re not limited, return an empty array<br>-&nbsp;&nbsp;&nbsp; return [] unless $self-&gt;_is_limited;<br>+&nbsp;&nbsp;&nbsp; unless ($self-&gt;_is_limited) {<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Carp::carp &quot;You may have wanted to use -&gt;limit or -&gt;unlimit on the collection&quot;;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return [];<br>+&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; # Do a search if we need to.<br>&nbsp;&nbsp;&nbsp;&nbsp; $self-&gt;_do_search() if $self-&gt;{&#39;must_redo_search&#39;};<br>@@ -1875,7 +1881,10 @@<br>&nbsp;&nbsp;&nbsp;&nbsp; my $self = shift;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; # An unlimited search returns no tickets<br>
-&nbsp;&nbsp;&nbsp; return 0 unless ( $self-&gt;_is_limited );<br>+&nbsp;&nbsp;&nbsp; unless ( $self-&gt;_is_limited ) {<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Carp::carp &quot;You may have wanted to use -&gt;limit or -&gt;unlimit on the collection&quot;;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>
+&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; # If we haven&#39;t actually got all objects loaded in memory, we<br>&nbsp;&nbsp;&nbsp;&nbsp; # really just want to do a quick count from the database.<br>@@ -1926,7 +1935,10 @@<br>&nbsp;&nbsp;&nbsp;&nbsp; my $self = shift;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; # An unlimited search returns no tickets<br>
-&nbsp;&nbsp;&nbsp; return 0 unless ( $self-&gt;_is_limited );<br>+&nbsp;&nbsp;&nbsp; unless ( $self-&gt;_is_limited ) {<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Carp::carp &quot;You may have wanted to use -&gt;limit or -&gt;unlimit on the collection&quot;;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0;<br>
+&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; # If we haven&#39;t actually got all objects loaded in memory, we<br>&nbsp;&nbsp;&nbsp;&nbsp; # really just want to do a quick count from the database.<br><br>Please let me know what you think.<br><br>Thanks,<br><br>Jason May<br>