Add list support, and various mini-fixes
[dbsrgits/SQL-Abstract.git] / lib / SQL / Abstract / Test.pm
index c6e909c..42491f9 100644 (file)
@@ -27,7 +27,7 @@ my @unrollable_ops = (
   'ORDER \s+ BY',
 );
 my $unrollable_ops_re = join ' | ', @unrollable_ops;
-$unrollable_ops_re = qr/$unrollable_ops_re/xio;
+$unrollable_ops_re = qr/$unrollable_ops_re/xi;
 
 sub is_same_sql_bind {
   my ($sql1, $bind_ref1, $sql2, $bind_ref2, $msg) = @_;
@@ -269,18 +269,24 @@ sub _parenthesis_unroll {
       }
 
       # a function binds tighter than a mathop - see if our ancestor is a
-      # mathop, and our content is a single non-mathop child with a single
-      # PAREN grandchild which would indicate mathop ( nonmathop ( ... ) )
+      # mathop, and our content is:
+      # a single non-mathop child with a single PAREN grandchild which
+      # would indicate mathop ( nonmathop ( ... ) )
+      # or a single non-mathop with a single LITERAL ( nonmathop ? )
       elsif (
         @{$child->[1]} == 1
           and
         @{$child->[1][0][1]} == 1
           and
-        $child->[1][0][1][0][0] eq 'PAREN'
-          and
         $ast->[0] =~ SQL::Abstract::Tree::_math_op_re()
           and
         $child->[1][0][0] !~ SQL::Abstract::Tree::_math_op_re
+          and
+        (
+          $child->[1][0][1][0][0] eq 'PAREN'
+            or 
+          $child->[1][0][1][0][0] eq 'LITERAL'
+        )
       ) {
         push @children, $child->[1][0];
         $changes++;