Skip to content

Commit

Permalink
remove icky ' = '
Browse files Browse the repository at this point in the history
  • Loading branch information
wdh committed Apr 19, 2006
1 parent a32e840 commit 8c91c8f
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions lib/DBIx/Class/ResultSet.pm
Expand Up @@ -195,44 +195,42 @@ call it as C<search(undef, \%attrs)>.

sub search {
my $self = shift;

my $rs;
if( @_ ) {

my $attrs = { %{$self->{attrs}} };
my $having = delete $attrs->{having};
$attrs = { %$attrs, %{ pop(@_) } } if @_ > 1 and ref $_[$#_] eq 'HASH';

my $where = (@_
? ((@_ == 1 || ref $_[0] eq "HASH")
? shift
: ((@_ % 2)
? $self->throw_exception(
"Odd number of arguments to search")
: {@_}))
: undef());
if (defined $where) {
$attrs->{where} = (defined $attrs->{where}
? { '-and' =>
[ map { ref $_ eq 'ARRAY' ? [ -or => $_ ] : $_ }
$where, $attrs->{where} ] }
: $where);
}

if (defined $having) {
$attrs->{having} = (defined $attrs->{having}
? { '-and' =>
[ map { ref $_ eq 'ARRAY' ? [ -or => $_ ] : $_ }
$having, $attrs->{having} ] }
: $having);
}
my $attrs = { %{$self->{attrs}} };
my $having = delete $attrs->{having};
$attrs = { %$attrs, %{ pop(@_) } } if @_ > 1 and ref $_[$#_] eq 'HASH';

my $where = (@_
? ((@_ == 1 || ref $_[0] eq "HASH")
? shift
: ((@_ % 2)
? $self->throw_exception(
"Odd number of arguments to search")
: {@_}))
: undef());
if (defined $where) {
$attrs->{where} = (defined $attrs->{where}
? { '-and' =>
[ map { ref $_ eq 'ARRAY' ? [ -or => $_ ] : $_ }
$where, $attrs->{where} ] }
: $where);
}

$rs = (ref $self)->new($self->result_source, $attrs);
if (defined $having) {
$attrs->{having} = (defined $attrs->{having}
? { '-and' =>
[ map { ref $_ eq 'ARRAY' ? [ -or => $_ ] : $_ }
$having, $attrs->{having} ] }
: $having);
}
else {
$rs = $self;
$rs->reset;

my $rs = (ref $self)->new($self->result_source, $attrs);

my $rows = $self->get_cache;
if( @{$rows} ) {
$rs->set_cache($rows);
}

return (wantarray ? $rs->all : $rs);
}

Expand Down

0 comments on commit 8c91c8f

Please sign in to comment.