teach between to work as a unop
Matt S Trout [Mon, 1 Apr 2019 01:30:54 +0000 (01:30 +0000)]
lib/SQL/Abstract.pm

index 285039b..0f524ff 100644 (file)
@@ -210,6 +210,11 @@ sub new {
     },
     -between => '_expand_between',
     -not_between => '_expand_between',
+    -op => sub {
+      my ($self, $node, $args) = @_;
+      my ($op, @opargs) = @$args;
+      +{ $node => [ $op, map $self->expand_expr($_), @opargs ] };
+    },
   };
 
   $opt{expand_op} = {
@@ -997,7 +1002,7 @@ sub _expand_between {
   }
   return +{ -op => [
     $op,
-    $self->expand_expr($k, -ident),
+    $self->expand_expr(ref($k) ? $k : { -ident => $k }),
     @rhs
   ] }
 }