[Rt-commit] rt branch, 4.2/cf-is-null-warnings, created. rt-4.2.4-97-g9e7f384

Kevin Falcone falcone at bestpractical.com
Fri Jun 6 12:14:50 EDT 2014


The branch, 4.2/cf-is-null-warnings has been created
        at  9e7f38419482cf1676816696b2d2ebc70e1a6635 (commit)

- Log -----------------------------------------------------------------
commit 9e7f38419482cf1676816696b2d2ebc70e1a6635
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Jun 6 11:50:56 2014 -0400

    Don't attempt to parse IP/Date(Time) CFs if value is NULL
    
    We pass NULL into the Date/IP parsing logic *before* we get to the check
    which says "Oh, are you saying CF.{foo} IS NULL?  Then just left join to
    OCFV and be done with it".  This causes warnings and errors in the logs
    from trying to parse NULL as a Date or IP.  We did the right thing and
    executed the LEFT JOIN anyway, but it caused a lot of noise.

diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index b8b2c2f..28c04c2 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -518,6 +518,31 @@ sub _LimitCustomField {
         return %args;
     };
 
+    # Special Limit (we can exit early)
+    # IS NULL and IS NOT NULL checks
+    if ( $op =~ /^IS( NOT)?$/i ) {
+        my ($ocfvalias, $CFs) = $self->_CustomFieldJoin( $cfkey, $cf, $ltype );
+        $self->_OpenParen( $args{SUBCLAUSE} );
+        $self->Limit(
+            %args,
+            ALIAS    => $ocfvalias,
+            FIELD    => ($column || 'id'),
+            OPERATOR => $op,
+            VALUE    => $value,
+        );
+        # See below for an explanation of this limit
+        $self->Limit(
+            ALIAS      => $CFs,
+            FIELD      => 'Name',
+            OPERATOR   => 'IS NOT',
+            VALUE      => 'NULL',
+            ENTRYAGGREGATOR => 'AND',
+            SUBCLAUSE  => $args{SUBCLAUSE},
+        ) if $CFs;
+        $self->_CloseParen( $args{SUBCLAUSE} );
+        return;
+    }
+
     ########## Content pre-parsing if we know things about the CF
     if ( blessed($cf) and delete $args{PREPARSE} ) {
         my $type = $cf->Type;
@@ -659,29 +684,6 @@ sub _LimitCustomField {
     }
 
     ########## Limits
-    # IS NULL and IS NOT NULL checks
-    if ( $op =~ /^IS( NOT)?$/i ) {
-        my ($ocfvalias, $CFs) = $self->_CustomFieldJoin( $cfkey, $cf, $ltype );
-        $self->_OpenParen( $args{SUBCLAUSE} );
-        $self->Limit(
-            %args,
-            ALIAS    => $ocfvalias,
-            FIELD    => ($column || 'id'),
-            OPERATOR => $op,
-            VALUE    => $value,
-        );
-        # See below for an explanation of this limit
-        $self->Limit(
-            ALIAS      => $CFs,
-            FIELD      => 'Name',
-            OPERATOR   => 'IS NOT',
-            VALUE      => 'NULL',
-            ENTRYAGGREGATOR => 'AND',
-            SUBCLAUSE  => $args{SUBCLAUSE},
-        ) if $CFs;
-        $self->_CloseParen( $args{SUBCLAUSE} );
-        return;
-    }
 
     my $single_value = !blessed($cf) || $cf->SingleValue;
     my $negative_op = ($op eq '!=' || $op =~ /\bNOT\b/i);

-----------------------------------------------------------------------


More information about the rt-commit mailing list