<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 26 Feb 2008, at 11:34, Alex Povolotsky wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Ash Berlin wrote:<br><blockquote type="cite"><br></blockquote><blockquote type="cite">On 26 Feb 2008, at 11:23, Alex Povolotsky wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">Hello!<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">I'm using (with Catalyst and TT) some simple code to count related data<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">[% FOREACH loc IN llist -%]<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">&lt;li&gt;[% loc.name %] : (&lt;a href="[% Catalyst.uri_for("edit/$loc.lid") %]&gt;Edit&lt;/a&gt;)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">[% loc.contacts.count+0 %] contacts (more): [% loc.servers.count+0 %] servers (more):<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">here will be traffic<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">[% END -%]<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Debugging SQL requests, I've found that both counts use "select *" instead of "select count(*)".<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Is it a bug or a feature? Maybe count should be better optimized?<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Alex.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">TT calls everything i list context. So that count method is actually TT's count vmethod.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">you want [% loc.contacts_rs.count %] to get SELECT COUNT(*) executed.<br></blockquote><br>Whooops... where is it documented?...<br><br>Alex.<br><br></blockquote></div><br><div>I lied. there is no count vemthod - which is why you needed the +0</div><div><br class="webkit-block-placeholder"></div><div>As for where its documened... somewhere in the Template Toolkit manual. the _rs methods are mentioned in Relationship docs of DBIC.</div><div><br class="webkit-block-placeholder"></div><div>Tho it could be more obvious, since currently there is just this snippet (and ones like it)</div><div><br class="webkit-block-placeholder"></div><div><blockquote type="cite" class=""><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial; font-size: 16px; "><a name="Return_Value:_$resultset_(scalar_context),_@row_objs_(list_context)">Return Value: $resultset (scalar context), @row_objs (list context)</a></span></blockquote><br></div><div>Might be nice if you prepare a doc patch stating more explicitly what happens when you call a method which would normally return an RS in scalar context (search, my_rels, etc.) in list context, with particularly mention of Template Toolkit (which calls *everything* in list context.</div><div><br class="webkit-block-placeholder"></div><div>Ash</div></body></html>