* New Features / Changes
- New method ResultSource columns_info method, returning multiple
pairs of column name/info at once
+ - $rs->search now throws when called in void context, as it makes
+ no sense (and is nearly always a sign of a bug/misdesign)
- NULL is now supplied unquoted to all debug-objects, in order to
differentiate between a real NULL and the string 'NULL'
sub search {
my $self = shift;
my $rs = $self->search_rs( @_ );
- return (wantarray ? $rs->all : $rs);
+
+ my $want = wantarray;
+ if ($want) {
+ return $rs->all;
+ }
+ elsif (defined $want) {
+ return $rs;
+ }
+ else {
+ $self->throw_exception ('->search is *not* a mutator, calling it in void context makes no sense');
+ }
}
=head2 search_rs
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema(no_deploy => 1);
+
+throws_ok {
+ $schema->resultset('Artist')->search
+} qr/\Qsearch is *not* a mutator/, 'Proper exception on search in void ctx';
+
+done_testing;
year => 2006,
}) foreach (@cd_titles);
- return $artist->cds;
+ return $artist->cds->all;
};
# Test checking of parameters