[Dbix-class] Overriding all()
Paul Makepeace
paulm at paulm.com
Thu Jun 3 09:39:12 GMT 2010
On Thu, Jun 3, 2010 at 02:32, Florian Ragwitz <rafl at debian.org> wrote:
> On Thu, Jun 03, 2010 at 02:01:11AM -0700, Paul Makepeace wrote:
>> This used to work, perhaps by accident of usage,
>>
>> package IDL::ResultSet::SiteTestimonial;
>> use base 'DBIx::Class::ResultSet';
>>
>> sub all {
>> my $self = shift;
>> return $self->search(
>> { visible => 'Y' }, { order_by => 'sort desc' });
>> }
>>
>> but now seeing a q[Deep recursion on subroutine
>> "DBIx::Class::ResultSet::search"] error. What's the BP way of doing
>> this?
>
> ->search, in list context, means ->search_rs->all. You're calling
> ->search in list context within your Rs->all method. That's why you end
> up recursing indefinitely.
Thanks, yeah. I was asking what the best practice way would be for
overriding all() to achieve the ends I am after, namely adding in a
couple of defaults. Like I say, this used to work possibly a long time
ago, but not now.
Paul
More information about the DBIx-Class
mailing list