From: Arthur Axel 'fREW' Schmidt Date: Sat, 29 Jan 2011 15:18:49 +0000 (-0600) Subject: cleaner handling of args X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=45932d5c6ea9abcd61e855fe6da7429ee6793bde;p=dbsrgits%2FSQL-Abstract.git cleaner handling of args --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 06c4ae9..61b537b 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -1028,20 +1028,20 @@ sub _where_op_OP { my ($k, $vals); - if (ref $_[2]) { - # $_[1] gets set to "op" ? + if (@_ == 3) { + # $_[1] gets set to "op" $vals = $_[2]; $k = ''; - } else { + } elsif (@_ == 4) { $k = $_[1]; - # $_[2] gets set to "op" ? + # $_[2] gets set to "op" $vals = $_[3]; } my $label = $self->_convert($self->_quote($k)); my $placeholder = $self->_convert('?'); - puke '-op must be an array' unless ref $vals eq 'ARRAY'; + puke 'argument to -op must be an arrayref' unless ref $vals eq 'ARRAY'; puke 'first arg for -op must be a scalar' unless !ref $vals->[0]; my ($op, @rest_of_vals) = @$vals; @@ -1063,7 +1063,8 @@ sub _where_op_OP { return ($sql, @bind); }, HASHREF => sub { - $self->_recurse_where( $val ); + my $method = $self->_METHOD_FOR_refkind("_where_hashpair", $val); + $self->$method('', $val); } }); push @all_sql, $sql;