Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 74581
Status: rejected
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: MARKLE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in:
  • 0.08195
  • 0.08195_01
  • 0.08195_02
  • 0.08196



Subject: can't call search() on $resultset by itself anymore
Why can't I do this anymore? my $schema = $ec->schema('Stuff'); my $rs = $schema->resultset('Thang'); $rs->search({ name => 'foo' }); dies: "->search is *not* a mutator, calling it in void context makes no sense" I think this change might have broken existing code where this could be useful. sub searchit { return shift->search({ name => 'foo' }) } my @wheresit = map $_->all, map searchit( $schema->resultset($_) ), qw( Thang Thing Thingy ) ; I also used to be able to re-use the same resultset object to run search again with new params, which reduced the amount of typing. Mark
Show quoted text
> sub searchit { return shift->search({ name => 'foo' }) } > my @wheresit = > map $_->all, > map searchit( $schema->resultset($_) ), > qw( Thang Thing Thingy ) > ; >
ok maybe this isn't a good example, it could be my @wheresit = map $_->all, map $schema->resultset($_)->search({ name => 'foo' }), qw( Thang Thing Thingy ) ; ... but it seemed useful to re-use the resultset object before. Maybe I am doing it the wrong way, in which case feel free to nix the bug report. Mark
Subject: Re: [rt.cpan.org #74581] can't call search() on $resultset by itself anymore
Date: Tue, 31 Jan 2012 20:05:21 -0500 (EST)
To: bug-DBIx-Class [...] rt.cpan.org
From: andrew [...] cleverdomain.org
This is busted because map gives search a list context, and so search returns a list of rows, not a resultset. To correct it, either change the search to search_rs, or else remove the map $_->all, since that's what you get in list context anyway. Sent from my android device. Show quoted text
-----Original Message----- From: Mark Hedges via RT <bug-DBIx-Class@rt.cpan.org> To: undisclosed-recipients:; Sent: Tue, 31 Jan 2012 7:59 PM Subject: [rt.cpan.org #74581] can't call search() on $resultset by itself anymore Queue: DBIx-Class Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=74581 >
> sub searchit { return shift->search({ name => 'foo' }) } > my @wheresit = > map $_->all, > map searchit( $schema->resultset($_) ), > qw( Thang Thing Thingy ) > ; >
ok maybe this isn't a good example, it could be my @wheresit = map $_->all, map $schema->resultset($_)->search({ name => 'foo' }), qw( Thang Thing Thingy ) ; ... but it seemed useful to re-use the resultset object before. Maybe I am doing it the wrong way, in which case feel free to nix the bug report. Mark
On Tue Jan 31 19:56:27 2012, MARKLE wrote: Show quoted text
> Why can't I do this anymore? > > my $schema = $ec->schema('Stuff'); > my $rs = $schema->resultset('Thang'); > $rs->search({ name => 'foo' }); > > dies: > "->search is *not* a mutator, calling it in void context makes no sense" >
Correct. When you have a resultset $rs, doing $rs->search('foo'); <do something else here> DOES NOT (never ever did) alter the $rs in any way (hence the "not a mutator" error message). Show quoted text
> I think this change might have broken existing code where this could be > useful. > > sub searchit { return shift->search({ name => 'foo' }) } > my @wheresit = > map $_->all, > map searchit( $schema->resultset($_) ), > qw( Thang Thing Thingy ) > ; >
I think you are wrong, the above shoud work just fine, given how the result of searchit is in list context, not void context. You need to review your code and find the exact exception callsite. The implementation detail is here: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits/DBIx-Class.git;a=blob;f=lib/DBIx/Class/ResultSet.pm;h=6cd23b1cc2d2adf1622a8086d6c1d553269b4718;hb=HEAD#l300
Given no response I am closing this ticket, and assuming that the error was in the user code, and has since been located and fixed. Feel free to reopen this ticket if this problem still persists.