[Bast-commits] r7349 -
SQL-Abstract/1.x/branches/bool_operator/lib/SQL
nigel at dev.catalyst.perl.org
nigel at dev.catalyst.perl.org
Thu Aug 20 09:55:53 GMT 2009
Author: nigel
Date: 2009-08-20 09:55:53 +0000 (Thu, 20 Aug 2009)
New Revision: 7349
Modified:
SQL-Abstract/1.x/branches/bool_operator/lib/SQL/Abstract.pm
Log:
Reduced regex munging of operators and streamlined backcompat syntax implementation.
Modified: SQL-Abstract/1.x/branches/bool_operator/lib/SQL/Abstract.pm
===================================================================
--- SQL-Abstract/1.x/branches/bool_operator/lib/SQL/Abstract.pm 2009-08-20 08:17:30 UTC (rev 7348)
+++ SQL-Abstract/1.x/branches/bool_operator/lib/SQL/Abstract.pm 2009-08-20 09:55:53 UTC (rev 7349)
@@ -31,9 +31,9 @@
# unaryish operators - key maps to handler
my @BUILTIN_UNARY_OPS = (
- { regex => qr/^and (\s? \d+)?$/xi, handler => '_where_op_ANDOR' },
- { regex => qr/^or (\s? \d+)?$/xi, handler => '_where_op_ANDOR' },
- { regex => qr/^nest (\s? \d+)?$/xi, handler => '_where_op_NEST' },
+ { regex => qr/^and (\s? \d+)?$/xi, handler => '_where_op_ANDOR', numchk => 1 },
+ { regex => qr/^or (\s? \d+)?$/xi, handler => '_where_op_ANDOR', numchk => 1 },
+ { regex => qr/^nest (\s? \d+)?$/xi, handler => '_where_op_NEST', numchk => 1 },
{ regex => qr/^(not \s?)? bool$/xi, handler => '_where_op_BOOL' },
);
@@ -457,10 +457,7 @@
# put the operator in canonical form
$op =~ s/^-//; # remove initial dash
- $op =~ tr/_/ /; # underscores become spaces
- $op =~ s/^\s+//; # no initial space
- $op =~ s/\s+$//; # no final space
- $op =~ s/\s+/ /; # multiple spaces become one
+ $op =~ tr/_ \t/ /s; # underscores and whitespace become single spaces
$self->_debug("OP(-$op) within hashref, recursing...");
@@ -470,6 +467,10 @@
puke "unknown operator: -$op";
}
elsif (not ref $handler) {
+ if ($op_entry->{numchk} && ($op =~ s/\s?\d+$//)) {
+ belch 'Use of [and|or|nest]_N modifiers is deprecated and will be removed in SQLA v2.0. '
+ . "You probably wanted ...-and => [ $op => COND1, $op => COND2 ... ]";
+ }
return $self->$handler ($op, $v);
}
elsif (ref $handler eq 'CODE') {
@@ -483,11 +484,6 @@
sub _where_op_ANDOR {
my ($self, $op, $v) = @_;
- if ($op =~ s/\s?\d+$//) {
- belch 'Use of [and|or|nest]_N modifiers is deprecated and will be removed in SQLA v2.0. '
- . "You probably wanted ...-and => [ $op => COND1, $op => COND2 ... ]";
- }
-
$self->_SWITCH_refkind($v, {
ARRAYREF => sub {
return $self->_where_ARRAYREF($v, $op);
@@ -520,12 +516,6 @@
sub _where_op_NEST {
my ($self, $op, $v) = @_;
- if ($op =~ s/\s?\d+$//) {
- belch 'Use of [and|or|nest]_N modifiers is deprecated and will be removed in SQLA v2.0. '
- . "You probably wanted ...-and => [ $op => COND1, $op => COND2 ... ]";
- }
-
-
$self->_SWITCH_refkind($v, {
ARRAYREF => sub {
More information about the Bast-commits
mailing list