kill vestigial _expand_noop method
[scpubgit/Q-Branch.git] / lib / SQL / Abstract.pm
index 503ac9c..476ca94 100644 (file)
@@ -144,9 +144,6 @@ our %Defaults = (
     op => '_expand_op',
     func => '_expand_func',
     values => '_expand_values',
-    bind => '_expand_noop',
-    literal => '_expand_noop',
-    keyword => '_expand_noop',
   },
   expand_op => {
     'between' => '_expand_between',
@@ -992,23 +989,26 @@ sub _expand_hashpair_op {
 
   my $op = $self->_normalize_op($k);
 
-  { # Old SQLA compat
+  my $wsop = join(' ', split '_', $op);
 
-    my $op = join(' ', split '_', $op);
+  my $is_special = List::Util::first { $wsop =~ $_->{regex} }
+                     @{$self->{special_ops}};
+
+  { # Old SQLA compat
 
     # the old special op system requires illegality for top-level use
 
     if (
       (our $Expand_Depth) == 1
       and (
-        List::Util::first { $op =~ $_->{regex} } @{$self->{special_ops}}
+        $is_special
         or (
           $self->{disable_old_special_ops}
-          and List::Util::first { $op =~ $_->{regex} } @BUILTIN_SPECIAL_OPS
+          and List::Util::first { $wsop =~ $_->{regex} } @BUILTIN_SPECIAL_OPS
         )
       )
     ) {
-      puke "Illegal use of top-level '-$op'"
+      puke "Illegal use of top-level '-$wsop'"
     }
   }
 
@@ -1016,6 +1016,10 @@ sub _expand_hashpair_op {
     return $self->$exp($op, $v);
   }
 
+  if ($self->{render}{$op}) {
+    return { "-${op}" => $v };
+  }
+
   # Ops prefixed with -not_ get converted
 
   if (my ($rest) = $op =~/^not_(.*)$/) {
@@ -1036,27 +1040,22 @@ sub _expand_hashpair_op {
     }
   }
 
-  my $type = (
-    $self->{unknown_unop_always_func} && !$self->{render_op}{$op}
-      ? -func
-      : -op
-  );
+  my $type = $is_special || $self->{render_op}{$op} ? -op : -func;
 
-  { # Old SQLA compat
+  if ($self->{restore_old_unop_handling}) {
+
+    # Old SQLA compat
 
     if (
       ref($v) eq 'HASH'
       and keys %$v == 1
       and (keys %$v)[0] =~ /^-/
+      and not $self->{render_op}{$op}
+      and not $is_special
     ) {
-      $type = (
-        (
-          (List::Util::first { $op =~ $_->{regex} } @{$self->{special_ops}})
-          or $self->{render_op}{$op}
-        )
-          ? -op
-          : -func
-      )
+      $type = -func;
+    } else {
+      $type = -op;
     }
   }
 
@@ -1353,11 +1352,6 @@ sub _expand_nest {
   return $self->_expand_expr($v);
 }
 
-sub _expand_noop {
-  my ($self, $type, $v) = @_;
-  return { "-${type}" => $v };
-}
-
 sub _expand_values {
   my ($self, undef, $values) = @_;
   return { -values => [
@@ -1433,7 +1427,9 @@ sub _render_literal {
 
 sub _render_keyword {
   my ($self, undef, $keyword) = @_;
-  return [ $self->_sqlcase(join ' ', split '_', $keyword) ];
+  return [ $self->_sqlcase(
+    ref($keyword) ? $$keyword : join ' ', split '_', $keyword
+  ) ];
 }
 
 sub _render_op {
@@ -1566,8 +1562,14 @@ sub _render_unop_paren {
 
 sub _render_unop_prefix {
   my ($self, $op, $v) = @_;
+  my $op_sql = $self->{restore_old_unop_handling}
+                 ? $self->_sqlcase($op)
+                 : { -keyword => $op };
   return $self->join_query_parts(' ',
-    $self->_sqlcase($op), $v->[0]
+    ($self->{restore_old_unop_handling}
+      ? $self->_sqlcase($op)
+      : { -keyword => \$op }),
+    $v->[0]
   );
 }