my $self = shift;
my $rs = $self->search_rs( @_ );
- my $want = wantarray;
- if ($want) {
+ if (wantarray) {
return $rs->all;
}
- elsif (defined $want) {
+ elsif (defined wantarray) {
return $rs;
}
else {
- $self->throw_exception ('->search is *not* a mutator, calling it in void context makes no sense');
+ # we can be called by a relationship helper, which in
+ # turn may be called in void context due to some braindead
+ # overload or whatever else the user decided to be clever
+ # at this particular day. Thus limit the exception to
+ # external code calls only
+ $self->throw_exception ('->search is *not* a mutator, calling it in void context makes no sense')
+ if (caller)[0] !~ /^\QDBIx::Class::/;
+
+ return ();
}
}
=cut
+my $callsites_warned;
sub search_rs {
my $self = shift;
} if @_;
- carp 'search( %condition ) is deprecated, use search( \%condition ) instead'
- if (@_ > 1 and ! $self->result_source->result_class->isa('DBIx::Class::CDBICompat') );
+ if( @_ > 1 and ! $self->result_source->result_class->isa('DBIx::Class::CDBICompat') ) {
+ # determine callsite obeying Carp::Clan rules (fucking ugly but don't have better ideas)
+ my $callsite = do {
+ my $w;
+ local $SIG{__WARN__} = sub { $w = shift };
+ carp;
+ $w
+ };
+ carp 'search( %condition ) is deprecated, use search( \%condition ) instead'
+ unless $callsites_warned->{$callsite}++;
+ }
for ($old_where, $call_cond) {
if (defined $_) {
sub is_ordered {
my ($self) = @_;
- return scalar $self->result_source->storage->_extract_order_columns($self->{attrs}{order_by});
+ return scalar $self->result_source->storage->_extract_order_criteria($self->{attrs}{order_by});
}
=head2 related_resultset
ORDER BY. It is applied to the after the grouping calculations have been
done.
- having => { 'count(employee)' => { '>=', 100 } }
+ having => { 'count_employee' => { '>=', 100 } }
+
+or with an in-place function in which case literal SQL is required:
+
+ having => \[ 'count(employee) >= ?', [ count => 100 ] ]
=head2 distinct