From: Dagfinn Ilmari Mannsåker Date: Mon, 19 Oct 2015 10:25:53 +0000 (+0100) Subject: Teach ::Tree that ILIKE (PostgreSQL) and REGEXP (MySQL) are binary ops X-Git-Tag: v1.81_01~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bf782d2ed543779ceb2dd6febffce9fa807faa5a;p=dbsrgits%2FSQL-Abstract.git Teach ::Tree that ILIKE (PostgreSQL) and REGEXP (MySQL) are binary ops --- diff --git a/Changes b/Changes index abc4287..b26028f 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for SQL::Abstract - Fix order clauses with bind parameters in ->where + - Teach ::Tree that ILIKE (PostgreSQL) and REGEXP (MySQL) are binary ops revision 1.81 2014-10-25 ---------------------------- diff --git a/lib/SQL/Abstract/Tree.pm b/lib/SQL/Abstract/Tree.pm index 75cf859..79e6ef3 100644 --- a/lib/SQL/Abstract/Tree.pm +++ b/lib/SQL/Abstract/Tree.pm @@ -78,7 +78,7 @@ my $alphanum_cmp_op_re = join ("\n\t|\n", map ); $alphanum_cmp_op_re = qr/$alphanum_cmp_op_re/x; -my $binary_op_re = '(?: NOT \s+)? (?:' . join ('|', qw/IN BETWEEN R?LIKE/) . ')'; +my $binary_op_re = '(?: NOT \s+)? (?:' . join ('|', qw/IN BETWEEN [RI]?LIKE REGEXP/) . ')'; $binary_op_re = join "\n\t|\n", "$op_look_behind (?i: $binary_op_re | AS ) $op_look_ahead", $alphanum_cmp_op_re, diff --git a/t/14roundtrippin.t b/t/14roundtrippin.t index bfb713f..2dd026b 100644 --- a/t/14roundtrippin.t +++ b/t/14roundtrippin.t @@ -30,6 +30,8 @@ my @sql = ( "SELECT [me].[id], ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS [rno__row__index] FROM ( SELECT [me].[id] FROM [LogParents] [me]) [me]", # deliberate batshit insanity "SELECT foo FROM bar WHERE > 12", + 'SELECT ilike_any_or FROM bar WHERE ( baz ILIKE ANY(?) OR bat ILIKE ANY(?) )', + 'SELECT regexp_or FROM bar WHERE ( baz REGEXP ? OR bat REGEXP ? )', ); # FIXME FIXME FIXME