[Templates] [PATCH] allow forcing scalar context to deal with ornery object methods
ogmoid at gmail.com
ogmoid at gmail.com
Mon Jan 21 23:26:51 GMT 2008
On Mon, Jan 21, 2008 at 04:49:42PM -0600, mike wrote:
> On Jan 21, 2008 11:04 AM, Andy Wardley <abw at wardley.org> wrote:
> > mike wrote:
[snip]
> honestly, i don't believe it to be TT's fault. the blame lies squarely
> with DBIx::Class. i loathe wantarray and DBIx::Class's liberal use of
> it. those of you familiar with DBIx::Class may know that relationship
> accessors or the ResultSet->search method will "optimize" for you by
> assuming that you want a list of objects (as would be returned by the
> ResultSet->all method) if called in list context. while this may
> typically be the case, it is not always so. this "optimization" robs
> the user of flexibility and control in exchange for not having to type
> ->all when you really mean it. in this case, DWIM fails to DTRT.
You've already agitated the Badger into action but there's another method. The
DBIC (read Catalyst) folks were annoyed about this problem a while ago and
created this:
[From DBIx::Class::ResultSet POD]
search_rs
Arguments: $cond, \%attrs?
Return Value: $resultset
This method does the same exact thing as search() except it will always return
a resultset, even in list context.
Regards,
--
Nate Nuss
More information about the templates
mailing list