From: Peter Rabbitson Date: Tue, 23 Mar 2010 21:50:09 +0000 (+0000) Subject: ILIKE is common enough to be in core X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2d2df6ba3a20ae57e0fb0844b294630c9038c0f7;p=scpubgit%2FQ-Branch.git ILIKE is common enough to be in core --- diff --git a/Changes b/Changes index 5e1e236..0377b38 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for SQL::Abstract + - Add ILIKE to the core list of comparision ops + revision 1.62 2010-03-15 11:06 (UTC) ---------------------------- - Fixed open outer parens for a multi-line literal diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 060e601..646cc23 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -84,7 +84,7 @@ sub new { # generic SQL comparison operators my $anchored_cmp_ops = join ('|', map { '^' . $_ . '$' } ( - '(?:is \s+)? (?:not \s+)? like', + '(?:is \s+)? (?:not \s+)? i? like', 'is', (map { quotemeta($_) } (qw/ < > != <> = <= >= /) ), )); diff --git a/t/01generate.t b/t/01generate.t index 9dbc504..8033c97 100644 --- a/t/01generate.t +++ b/t/01generate.t @@ -262,13 +262,13 @@ my @tests = ( #29 { func => 'select', - args => ['jeff', '*', { name => {'like', '%smith%', -not_in => ['Nate','Jim','Bob','Sally']}, + args => ['jeff', '*', { name => {'ilike', '%smith%', -not_in => ['Nate','Jim','Bob','Sally']}, -nest => [ -or => [ -and => [age => { -between => [20,30] }, age => {'!=', 25} ], yob => {'<', 1976} ] ] } ], stmt => 'SELECT * FROM jeff WHERE ( ( ( ( ( ( ( age BETWEEN ? AND ? ) AND ( age != ? ) ) ) OR ( yob < ? ) ) ) )' - . ' AND name NOT IN ( ?, ?, ?, ? ) AND name LIKE ? )', + . ' AND name NOT IN ( ?, ?, ?, ? ) AND name ILIKE ? )', stmt_q => 'SELECT * FROM `jeff` WHERE ( ( ( ( ( ( ( `age` BETWEEN ? AND ? ) AND ( `age` != ? ) ) ) OR ( `yob` < ? ) ) ) )' - . ' AND `name` NOT IN ( ?, ?, ?, ? ) AND `name` LIKE ? )', + . ' AND `name` NOT IN ( ?, ?, ?, ? ) AND `name` ILIKE ? )', bind => [qw(20 30 25 1976 Nate Jim Bob Sally %smith%)] }, #30