From: Peter Rabbitson Date: Mon, 6 Jan 2014 14:14:48 +0000 (+0100) Subject: Cleanup regexes / reduce captures a bit X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5245699d8ed21cf994541a1bd79b66f69a9b238b;p=dbsrgits%2FSQL-Abstract.git Cleanup regexes / reduce captures a bit --- diff --git a/lib/SQL/Abstract/Converter.pm b/lib/SQL/Abstract/Converter.pm index e89ae42..c4c8295 100644 --- a/lib/SQL/Abstract/Converter.pm +++ b/lib/SQL/Abstract/Converter.pm @@ -162,7 +162,7 @@ sub _mutation_rhs_to_dq { my ($op, $arg, @rest) = %$v; die 'Operator calls in update/insert must be in the form { -op => $arg }' - if (@rest or not $op =~ /^\-(.+)/); + if (@rest or not $op =~ /^\-/); } return $self->_expr_to_dq($v); } @@ -465,7 +465,7 @@ sub _where_hashpair_to_dq { } my ($op, $value) = %$v; s/^-//, s/_/ /g for $op; - if ($op =~ /^(and|or)$/i) { + if ($op =~ /^(?:and|or)$/i) { return $self->_expr_to_dq({ $k => $value }, $op); } elsif ( my $special_op = List::Util::first {$op =~ $_->{regex}} @@ -473,7 +473,7 @@ sub _where_hashpair_to_dq { ) { return $self->_literal_to_dq( [ $special_op->{handler}->($k, $op, $value) ] - );; + ); } elsif ($op =~ /^(?:AND|OR|NEST)_?\d+$/i) { die "Use of [and|or|nest]_N modifiers is no longer supported"; } @@ -486,7 +486,7 @@ sub _where_hashpair_to_dq { die "Argument passed to the '$op' operator can not be undefined" unless defined $rhs; $rhs = [$rhs] unless ref $rhs; if (ref($rhs) ne 'ARRAY') { - if ($op =~ /IN$/) { + if ($op =~ /^(?:NOT )?IN$/) { # have to add parens if none present because -in => \"SELECT ..." # got documented. mst hates everything. if (ref($rhs) eq 'SCALAR') {