[Rt-commit] r4145 - in rt/branches/QUEBEC-EXPERIMENTAL: . lib/RT lib/t/regression

alexmv at bestpractical.com alexmv at bestpractical.com
Wed Nov 23 16:32:26 EST 2005


Author: alexmv
Date: Wed Nov 23 16:32:25 2005
New Revision: 4145

Modified:
   rt/branches/QUEBEC-EXPERIMENTAL/   (props changed)
   rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm
   rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/12-search.t
   rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/20-sort-by-requestor.t
Log:
 r7341 at zoq-fot-pik:  chmrr | 2005-11-23 16:31:44 -0500
  * Limiting based on CFs should make sure that the CFs in question are
 on the right queue, otherwise negative searches might be wrong.
  * Removed debugging lines from 20-sort-by-requestor.t


Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm	(original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm	Wed Nov 23 16:32:25 2005
@@ -135,7 +135,7 @@
     Requestors       => [ 'WATCHERFIELD'    => 'Requestor', ],
     Cc               => [ 'WATCHERFIELD'    => 'Cc', ],
     AdminCc          => [ 'WATCHERFIELD'    => 'AdminCc', ],
-    Watcher          => ['WATCHERFIELD'],
+    Watcher          => [ 'WATCHERFIELD', ],
     LinkedTo         => [ 'LINKFIELD', ],
     CustomFieldValue => [ 'CUSTOMFIELD', ],
     CF               => [ 'CUSTOMFIELD', ],
@@ -1207,6 +1207,7 @@
     }
 
     my $TicketCFs;
+    my $CFs;
     my $cfkey = $cfid ? $cfid : "$queue.$field";
 
     # Perform one Join per CustomField
@@ -1230,16 +1231,23 @@
             );
         }
         else {
-            my $cfalias = $self->Join(
+            my $ocfalias = $self->Join(
                 TYPE       => 'left',
-                EXPRESSION => "'$field'",
+                FIELD1     => 'Queue',
+                TABLE2     => 'ObjectCustomFields',
+                FIELD2     => 'ObjectId',
+            );
+            $CFs = $self->Join(
+                TYPE       => 'left',
+                ALIAS1     => $ocfalias,
+                FIELD1     => 'CustomField',
                 TABLE2     => 'CustomFields',
-                FIELD2     => 'Name',
+                FIELD2     => 'id',
             );
 
             $TicketCFs = $self->{_sql_object_cf_alias}{$cfkey} = $self->Join(
                 TYPE   => 'left',
-                ALIAS1 => $cfalias,
+                ALIAS1 => $CFs,
                 FIELD1 => 'id',
                 TABLE2 => 'ObjectCustomFieldValues',
                 FIELD2 => 'CustomField',
@@ -1267,8 +1275,16 @@
         );
     }
 
-    $self->_OpenParen if ($null_columns_ok);
+    $self->_OpenParen;
+
+    $self->SUPER::Limit(
+        ALIAS           => $CFs,
+        FIELD           => 'name',
+        VALUE           => $field,
+        ENTRYAGGREGATOR => 'AND',
+    );
 
+    $self->_OpenParen if $null_columns_ok;
     $self->_SQLLimit(
         ALIAS      => $TicketCFs,
         FIELD      => 'Content',
@@ -1288,7 +1304,9 @@
             ENTRYAGGREGATOR => 'OR',
         );
     }
-    $self->_CloseParen if ($null_columns_ok);
+    $self->_CloseParen if $null_columns_ok;
+
+    $self->_CloseParen;
 
 }
 

Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/12-search.t
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/12-search.t	(original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/12-search.t	Wed Nov 23 16:32:25 2005
@@ -6,7 +6,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 35;
+use Test::More tests => 39;
 use_ok('RT');
 RT::LoadConfig();
 RT::Init();
@@ -38,6 +38,24 @@
 my $cflabel3 = "CustomField-".$cf3->id;
 
 
+# There was a bug involving a missing join to ObjectCustomFields that
+# caused spurious results on negative searches if another custom field
+# with the same name existed on a different queue.  Hence, we make
+# duplicate CFs on a different queue here
+my $dup = RT::Queue->new($RT::SystemUser);
+$dup->Create(Name => $queue . "-Copy");
+ok ($dup->id, "Created the duplicate queue");
+my $dupcf = RT::CustomField->new($RT::SystemUser);
+$dupcf->Create(Name => 'SearchTest', Type => 'Freeform', MaxValues => 0, Queue => $dup->id);
+ok($dupcf->id, "Created the duplicate SearchTest CF");
+$dupcf = RT::CustomField->new($RT::SystemUser);
+$dupcf->Create(Name => 'SearchTest2', Type => 'Freeform', MaxValues => 0, Queue => $dup->id);
+ok($dupcf->id, "Created the SearchTest2 CF");
+$dupcf = RT::CustomField->new($RT::SystemUser);
+$dupcf->Create(Name => 'SearchTest3', Type => 'Freeform', MaxValues => 0, Queue => $dup->id);
+ok($dupcf->id, "Created the SearchTest3 CF");
+
+
 # setup some tickets
 # we'll need a small pile of them, to test various combinations and nulls.
 # there's probably a way to think harder and do this with fewer
@@ -148,8 +166,7 @@
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND CF.SearchTest IS NULL");
-    
-    is($tix->Count, 2, "IS null CF");
+is($tix->Count, 2, "IS null CF");
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND Requestors LIKE 'search1'");
@@ -218,13 +235,11 @@
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("CF.SearchTest IS NULL AND CF.SearchTest2 = 'bar2'");
-    
-    is($tix->Count, 1, "null cf and is cf");
+is($tix->Count, 1, "null cf and is cf");
 
 
 $tix = RT::Tickets->new($RT::SystemUser);
 $tix->FromSQL("Queue = '$queue' AND CF.SearchTest IS NULL AND CF.SearchTest2 IS NULL");
-
-        is($tix->Count, 1, "null cf and null cf"); 
+is($tix->Count, 1, "null cf and null cf"); 
 
 

Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/20-sort-by-requestor.t
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/20-sort-by-requestor.t	(original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/t/regression/20-sort-by-requestor.t	Wed Nov 23 16:32:25 2005
@@ -49,7 +49,6 @@
     while (my $t = $tix->Next) { push @mails, $t->RequestorAddresses; }
     is(@mails, 5, "found five tickets");
     is_deeply( \@mails, [ sort @mails ], "Addresses are sorted");
-    print STDERR "Emails are ", join(" ", map {defined $_ ? $_ : "undef"} @mails);
 }
 
 {
@@ -60,7 +59,6 @@
     while (my $t = $tix->Next) { push @mails, $t->RequestorAddresses; }
     is(@mails, 6, "found six tickets");
     is_deeply( \@mails, [ sort @mails ], "Addresses are sorted");
-    print STDERR "Emails are ", join(" ", map {defined $_ ? $_ : "undef"} @mails);
 }
 
 # vim:ft=perl:


More information about the Rt-commit mailing list