Skip Menu |

This queue is for tickets about the Template-Toolkit CPAN distribution.

Report information
The Basics
Id: 23763
Status: resolved
Worked: 12 min
Priority: 0/
Queue: Template-Toolkit

People
Owner: Nobody in particular
Requestors: ddascalescu+perl [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: resultset.result_source is evaluated in numeric context
In a Catalyst application: $c->stash{itemsrs} = $c->model('MyApp::String')->search(...); In a TT file: [% itemsrs.result_source %] causes a SELECT COUNT(*) FROM ... me. This is a performance penalty for PostgreSQL: in my setup, it causes a 0.5s delay for a 300k record table. An excerpt from #tt: [09:45] <mst> ash: rs.result_source [09:45] <mst> ash: evaluates rs in numeric context at some point [09:45] <mst> ash: thus triggering a COUNT(*) [09:45] <mst> there is no reason at all for it to be doing that [09:46] <ash> numeric like mst said perhaps >_> [09:46] * quicksilver nods [09:50] <mst> it's got to be numeric context [09:50] <mst> resultsets numify to $self->count [09:50] <ash> i wasnt aware of that [09:50] <mst> for consistency on numeric ops whether you've got a $rs or @records
On Mon Dec 04 13:02:53 2006, dandv wrote: Show quoted text
> [09:50] <mst> it's got to be numeric context
I believe this was fixed in v2.19. I've added some tests to TT that (appear to) confirm that TT is doing the right thing. http://template-toolkit.org/svnweb/Template2/revision/?rev=1133 The tests show overloaded stringification methods are called and the overloaded numification methods are ignored. Based on this assumption, I'll close the bug. Please re-open it if you think it still exists.
On Wed Aug 06 09:14:02 2008, ABW wrote: Show quoted text
> I've added some tests to TT that (appear to) confirm that TT is doing > the right thing.
Due to some dumbness on my part, the failure to reproduce the error was because I was using the XS stash (which doesn't appear to have the problem) and not the Perl stash (which does, it seems). Testing it with the Perl stash I was able to reproduce the problem (or at least, what I believe is the root cause of the problem) and subsequently fix it.