[Rt-commit] r18558 - rt/3.8/trunk/lib/RT

ruz at bestpractical.com ruz at bestpractical.com
Tue Feb 24 06:43:08 EST 2009


Author: ruz
Date: Tue Feb 24 06:41:01 2009
New Revision: 18558

Modified:
   rt/3.8/trunk/lib/RT/Tickets_Overlay_SQL.pm

Log:
* wrap things we usually do with operations into a method

Modified: rt/3.8/trunk/lib/RT/Tickets_Overlay_SQL.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Tickets_Overlay_SQL.pm	(original)
+++ rt/3.8/trunk/lib/RT/Tickets_Overlay_SQL.pm	Tue Feb 24 06:41:01 2009
@@ -350,6 +350,32 @@
 }
 
 
+sub ClassifySQLOperation {
+    my $self = shift;
+    my $op = shift;
+
+    my $is_negative = 0;
+    if ( $op eq '!=' || $op =~ /\bNOT\b/i ) {
+        $is_negative = 1;
+    }
+
+    my $is_null = 0;
+    if ( 'is not' eq lc($op) || 'is' eq lc($op) ) {
+        $is_null = 1;
+    }
+
+    my %inv = (
+        '=' => '!=', '!=' => '=', '<>' => '=',
+        '>' => '<=', '<' => '>=', '>=' => '<', '<=' => '>',
+        'is' => 'IS NOT', 'is not' => 'IS',
+        'like' => 'NOT LIKE', 'not like' => 'LIKE',
+        'matches' => 'NOT MATCHES', 'not matches' => 'MATCHES',
+        'startswith' => 'NOT STARTSWITH', 'not startswith' => 'STARTSWITH',
+        'endswith' => 'NOT ENDSWITH', 'not endswith' => 'ENDSWITH',
+    );
+
+    return ($is_negative, $is_null, $inv{lc $op});
+}
 
 1;
 


More information about the Rt-commit mailing list