[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-789-g7838610

Ruslan Zakirov ruz at bestpractical.com
Thu Sep 16 22:21:20 EDT 2010


The branch, 3.9-trunk has been updated
       via  783861005075680981d55a5f60e074d69f61440f (commit)
       via  dce7a18ca8839dece0101b2e4c44613c8c0afc8b (commit)
       via  f77202f6a06ebdec8fa30dae9271dfe81f728998 (commit)
       via  cdae5ea2494777e1e087aa2ae5fd01e90d4a813d (commit)
       via  9943ba8f53942b41cf184a6a007374cc897ce957 (commit)
      from  e5dbe37e795630011fb113e000f72baca8f83433 (commit)

Summary of changes:
 lib/RT/Tickets_Overlay.pm    |   55 +++-----
 t/ticket/search_by_watcher.t |  308 +++++++++++++++++++++--------------------
 2 files changed, 176 insertions(+), 187 deletions(-)

- Log -----------------------------------------------------------------
commit 9943ba8f53942b41cf184a6a007374cc897ce957
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 17 06:10:19 2010 +0400

    rewrite tests for searches by watchers

diff --git a/t/ticket/search_by_watcher.t b/t/ticket/search_by_watcher.t
index 57c3a46..fb4e6e6 100644
--- a/t/ticket/search_by_watcher.t
+++ b/t/ticket/search_by_watcher.t
@@ -3,14 +3,14 @@
 use strict;
 use warnings;
 
-use RT::Test nodata => 1, tests => 119;
+use RT::Test nodata => 1, tests => 1974;
 use RT::Ticket;
 
 my $q = RT::Test->load_or_create_queue( Name => 'Regression' );
 ok $q && $q->id, 'loaded or created queue';
 my $queue = $q->Name;
 
-my ($total, @data, @tickets, %test) = (0, ());
+my ($total, @data, @tickets, @test, @conditions) = (0, ());
 
 sub add_tix_from_data {
     my @res = ();
@@ -27,172 +27,180 @@ sub add_tix_from_data {
     return @res;
 }
 
-sub run_tests {
-    my $query_prefix = join ' OR ', map 'id = '. $_->id, @tickets;
-    foreach my $key ( sort keys %test ) {
-        my $tix = RT::Tickets->new($RT::SystemUser);
-        $tix->FromSQL( "( $query_prefix ) AND ( $key )" );
-
-        my $error = 0;
-
-        my $count = 0;
-        $count++ foreach grep $_, values %{ $test{$key} };
-        is($tix->Count, $count, "found correct number of ticket(s) by '$key'") or $error = 1;
-
-        my $good_tickets = ($tix->Count == $count);
-        while ( my $ticket = $tix->Next ) {
-            next if $test{$key}->{ $ticket->Subject };
-            diag $ticket->Subject ." ticket has been found when it's not expected";
-            $good_tickets = 0;
+sub generate_tix {
+    my @list = (
+        [],
+        ['x at foo.com'], ['y at bar.com'], ['z at bar.com'],
+        ['x at foo.com', 'y at bar.com'],
+        ['y at bar.com', 'z at bar.com'],
+        ['x at foo.com', 'z at bar.com'],
+        ['x at foo.com', 'y at bar.com', 'z at bar.com'],
+    );
+    @data = ();
+    foreach my $r (@list) {
+        foreach my $c (@list) {
+            my $subject = 'r:'. (join( '', map substr($_, 0, 1), @$r ) || '-') .';';
+            $subject .= 'c:'. (join( '', map substr($_, 0, 1), @$c ) || '-') .';';
+
+            push @data, {
+                Subject => $subject,
+                Requestor => $r,
+                Cc => $c,
+            };
         }
-        ok( $good_tickets, "all tickets are good with '$key'" ) or $error = 1;
-
-        diag "Wrong SQL query for '$key':". $tix->BuildSelectQuery if $error;
     }
+    return add_tix_from_data();
 }
 
- at data = (
-    { Subject => 'xy', Requestor => ['x at example.com', 'y at example.com'] },
-    { Subject => 'x', Requestor => 'x at example.com' },
-    { Subject => 'y', Requestor => 'y at example.com' },
-    { Subject => '-', },
-    { Subject => 'z', Requestor => 'z at example.com' },
-);
-%test = (
-    'Requestor = "x at example.com"'  => { xy => 1, x => 1, y => 0, '-' => 0, z => 0 },
-    'Requestor != "x at example.com"' => { xy => 0, x => 0, y => 1, '-' => 1, z => 1 },
-
-    'Requestor = "y at example.com"'  => { xy => 1, x => 0, y => 1, '-' => 0, z => 0 },
-    'Requestor != "y at example.com"' => { xy => 0, x => 1, y => 0, '-' => 1, z => 1 },
+sub run_tests {
+    while ( my ($query, $checks) = splice @test, 0, 2 ) {
+        run_test( $query, %$checks );
+    }
+}
 
-    'Requestor LIKE "@example.com"'     => { xy => 1, x => 1, y => 1, '-' => 0, z => 1 },
-    'Requestor NOT LIKE "@example.com"' => { xy => 0, x => 0, y => 0, '-' => 1, z => 0 },
+sub run_test {
+    my ($query, %checks) = @_;
+    my $query_prefix = join ' OR ', map 'id = '. $_->id, @tickets;
 
-    'Requestor IS NULL'            => { xy => 0, x => 0, y => 0, '-' => 1, z => 0 },
-    'Requestor IS NOT NULL'        => { xy => 1, x => 1, y => 1, '-' => 0, z => 1 },
+    my $tix = RT::Tickets->new($RT::SystemUser);
+    $tix->FromSQL( "( $query_prefix ) AND ( $query )" );
 
-# this test is a todo, we run it later
-#    'Requestor = "x at example.com" AND Requestor = "y at example.com"'   => { xy => 1, x => 0, y => 0, '-' => 0, z => 0 },
-    'Requestor = "x at example.com" OR Requestor = "y at example.com"'    => { xy => 1, x => 1, y => 1, '-' => 0, z => 0 },
+    my $error = 0;
 
-    'Requestor != "x at example.com" AND Requestor != "y at example.com"' => { xy => 0, x => 0, y => 0, '-' => 1, z => 1 },
-    'Requestor != "x at example.com" OR Requestor != "y at example.com"'  => { xy => 0, x => 1, y => 1, '-' => 1, z => 1 },
+    my $count = 0;
+    $count++ foreach grep $_, values %checks;
+    is($tix->Count, $count, "found correct number of ticket(s) by '$query'") or $error = 1;
 
-    'Requestor = "x at example.com" AND Requestor != "y at example.com"'  => { xy => 0, x => 1, y => 0, '-' => 0, z => 0 },
-    'Requestor = "x at example.com" OR Requestor != "y at example.com"'   => { xy => 1, x => 1, y => 0, '-' => 1, z => 1 },
+    my $good_tickets = ($tix->Count == $count);
+    while ( my $ticket = $tix->Next ) {
+        next if $checks{ $ticket->Subject };
+        diag $ticket->Subject ." ticket has been found when it's not expected";
+        $good_tickets = 0;
+    }
+    ok( $good_tickets, "all tickets are good with '$query'" ) or $error = 1;
 
-    'Requestor != "x at example.com" AND Requestor = "y at example.com"'  => { xy => 0, x => 0, y => 1, '-' => 0, z => 0 },
-    'Requestor != "x at example.com" OR Requestor = "y at example.com"'   => { xy => 1, x => 0, y => 1, '-' => 1, z => 1 },
-);
- at tickets = add_tix_from_data();
-{
-    my $tix = RT::Tickets->new($RT::SystemUser);
-    $tix->FromSQL("Queue = '$queue'");
-    is($tix->Count, $total, "found $total tickets");
+    diag "Wrong SQL query for '$query':". $tix->BuildSelectQuery if $error;
 }
-run_tests();
-
-# mixing searches by watchers with other conditions
-# http://rt3.fsck.com/Ticket/Display.html?id=9322
-%test = (
-    'Subject LIKE "x" AND Requestor = "y at example.com"' =>
-        { xy => 1, x => 0, y => 0, '-' => 0, z => 0 },
-    'Subject NOT LIKE "x" AND Requestor = "y at example.com"' =>
-        { xy => 0, x => 0, y => 1, '-' => 0, z => 0 },
-    'Subject LIKE "x" AND Requestor != "y at example.com"' =>
-        { xy => 0, x => 1, y => 0, '-' => 0, z => 0 },
-    'Subject NOT LIKE "x" AND Requestor != "y at example.com"' =>
-        { xy => 0, x => 0, y => 0, '-' => 1, z => 1 },
-
-    'Subject LIKE "x" OR Requestor = "y at example.com"' =>
-        { xy => 1, x => 1, y => 1, '-' => 0, z => 0 },
-    'Subject NOT LIKE "x" OR Requestor = "y at example.com"' =>
-        { xy => 1, x => 0, y => 1, '-' => 1, z => 1 },
-    'Subject LIKE "x" OR Requestor != "y at example.com"' =>
-        { xy => 1, x => 1, y => 0, '-' => 1, z => 1 },
-    'Subject NOT LIKE "x" OR Requestor != "y at example.com"' =>
-        { xy => 0, x => 1, y => 1, '-' => 1, z => 1 },
-
-# group of cases when user doesn't exist in DB at all
-    'Subject LIKE "x" AND Requestor = "not-exist at example.com"' =>
-        { xy => 0, x => 0, y => 0, '-' => 0, z => 0 },
-    'Subject NOT LIKE "x" AND Requestor = "not-exist at example.com"' =>
-        { xy => 0, x => 0, y => 0, '-' => 0, z => 0 },
-    'Subject LIKE "x" AND Requestor != "not-exist at example.com"' =>
-        { xy => 1, x => 1, y => 0, '-' => 0, z => 0 },
-    'Subject NOT LIKE "x" AND Requestor != "not-exist at example.com"' =>
-        { xy => 0, x => 0, y => 1, '-' => 1, z => 1 },
-#    'Subject LIKE "x" OR Requestor = "not-exist at example.com"' =>
-#        { xy => 1, x => 1, y => 0, '-' => 0, z => 0 },
-#    'Subject NOT LIKE "x" OR Requestor = "not-exist at example.com"' =>
-#        { xy => 0, x => 0, y => 1, '-' => 1, z => 1 },
-    'Subject LIKE "x" OR Requestor != "not-exist at example.com"' =>
-        { xy => 1, x => 1, y => 1, '-' => 1, z => 1 },
-    'Subject NOT LIKE "x" OR Requestor != "not-exist at example.com"' =>
-        { xy => 1, x => 1, y => 1, '-' => 1, z => 1 },
-
-    'Subject LIKE "z" AND (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
-        { xy => 0, x => 0, y => 0, '-' => 0, z => 0 },
-    'Subject NOT LIKE "z" AND (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
-        { xy => 1, x => 1, y => 1, '-' => 0, z => 0 },
-    'Subject LIKE "z" OR (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
-        { xy => 1, x => 1, y => 1, '-' => 0, z => 1 },
-    'Subject NOT LIKE "z" OR (Requestor = "x at example.com" OR Requestor = "y at example.com")' =>
-        { xy => 1, x => 1, y => 1, '-' => 1, z => 0 },
-);
-run_tests();
-
-TODO: {
-    local $TODO = "we can't generate this query yet";
-    %test = (
-        'Requestor = "x at example.com" AND Requestor = "y at example.com"'
-            => { xy => 1, x => 0, y => 0, '-' => 0, z => 0 },
-        'Subject LIKE "x" OR Requestor = "not-exist at example.com"' =>
-            { xy => 1, x => 1, y => 0, '-' => 0, z => 0 },
-        'Subject NOT LIKE "x" OR Requestor = "not-exist at example.com"' =>
-            { xy => 0, x => 0, y => 1, '-' => 1, z => 1 },
+
+sub run_auto_tests {
+    {
+        my @atmp = @conditions;
+        while ( my ($query, $cb) = splice @atmp, 0, 2 ) {
+            my %checks = ();
+            foreach my $ticket ( @tickets ) {
+                my $s = $ticket->Subject;
+                $checks{ $s } = $cb->($s);
+            }
+            run_test($query, %checks);
+        }
+    }
+    my @queries = (
+        '? AND ?'  => sub { $_[0] and $_[1] },
+        '? OR  ?' => sub  { $_[0] or $_[1] },
     );
-    run_tests();
+    while ( my ($template, $t_cb) = splice @queries, 0, 2 ) {
+        my @atmp = @conditions;
+        while ( my ($a, $a_cb) = splice @atmp, 0, 2 ) {
+        my @btmp = @conditions;
+        while ( my ($b, $b_cb) = splice @btmp, 0, 2 ) {
+        next if $a eq $b;
+
+            my %checks = ();
+            foreach my $ticket ( @tickets ) {
+                my $s = $ticket->Subject;
+                $checks{ $s } = $t_cb->( scalar $a_cb->($s), scalar $b_cb->($s) );
+            }
+
+            my $query = $template;
+            foreach my $tmp ($a, $b) {
+                $query =~ s/\?/$tmp/;
+            }
+
+            run_test( $query, %checks );
+        } }
+    }
+# XXX: It
+#    @queries = (
+#        '? AND ? AND ?'  => sub { $_[0] and $_[1] and $_[2] },
+#        '(? OR ?) AND ?' => sub { return (($_[0] or $_[1]) and $_[2]) },
+#        '? OR (? AND ?)' => sub { $_[0] or ($_[1] and $_[2]) },
+#        '(? AND ?) OR ?' => sub { ($_[0] and $_[1]) or $_[2] },
+#        '? AND (? OR ?)' => sub { $_[0] and ($_[1] or $_[2]) },
+#        '? OR ? OR ?'    => sub { $_[0] or $_[1] or $_[2] },
+#    );
+#    while ( my ($template, $t_cb) = splice @queries, 0, 2 ) {
+#        my @atmp = @conditions;
+#        while ( my ($a, $a_cb) = splice @atmp, 0, 2 ) {
+#        my @btmp = @conditions;
+#        while ( my ($b, $b_cb) = splice @btmp, 0, 2 ) {
+#        next if $a eq $b;
+#        my @ctmp = @conditions;
+#        while ( my ($c, $c_cb) = splice @ctmp, 0, 2 ) {
+#        next if $a eq $c;
+#        next if $b eq $c;
+#
+#            my %checks = ();
+#            foreach my $ticket ( @tickets ) {
+#                my $s = $ticket->Subject;
+#                $checks{ $s } = $t_cb->( scalar $a_cb->($s), scalar $b_cb->($s), scalar $c_cb->($s) );
+#            }
+#
+#            my $query = $template;
+#            foreach my $tmp ($a, $b, $c) {
+#                $query =~ s/\?/$tmp/;
+#            }
+#
+#            run_test( $query, %checks );
+#        } } }
+#    }
+
 }
 
- at data = (
-    { Subject => 'xy', Cc => ['x at example.com'], Requestor => [ 'y at example.com' ] },
-    { Subject => 'x-', Cc => ['x at example.com'], Requestor => [] },
-    { Subject => '-y', Cc => [],                Requestor => [ 'y at example.com' ] },
-    { Subject => '-', },
-    { Subject => 'zz', Cc => ['z at example.com'], Requestor => [ 'z at example.com' ] },
-    { Subject => 'z-', Cc => ['z at example.com'], Requestor => [] },
-    { Subject => '-z', Cc => [],                Requestor => [ 'z at example.com' ] },
+ at conditions = (
+    'Cc = "not at exist"'       => sub { 0 },
+    'Cc != "not at exist"'      => sub { 1 },
+    'Cc IS NULL'             => sub { $_[0] =~ 'c:-;' },
+    'Cc IS NOT NULL'         => sub { $_[0] !~ 'c:-;' },
+    'Cc = "x at foo.com"'       => sub { $_[0] =~ /c:[^;]*x/ },
+    'Cc != "x at foo.com"'      => sub { $_[0] !~ /c:[^;]*x/ },
+    'Cc LIKE "@bar.com"'     => sub { $_[0] =~ /c:[^;]*(?:y|z)/ },
+# TODO:
+#    'Cc NOT LIKE "@bar.com"' => sub { $_[0] !~ /y|z/ },
+
+    'Requestor = "not at exist"'   => sub { 0 },
+    'Requestor != "not at exist"'  => sub { 1 },
+    'Requestor IS NULL'         => sub { $_[0] =~ 'r:-;' },
+    'Requestor IS NOT NULL'     => sub { $_[0] !~ 'r:-;' },
+    'Requestor = "x at foo.com"'   => sub { $_[0] =~ /r:[^;]*x/ },
+    'Requestor != "x at foo.com"'  => sub { $_[0] !~ /r:[^;]*x/ },
+    'Requestor LIKE "@bar.com"' => sub { $_[0] =~ /r:[^;]*(?:y|z)/ },
+# TODO:
+#    'Requestor NOT LIKE "@bar.com"' => sub { $_[0] !~ /y|z/ },
+
+    'Watcher = "not at exist"'   => sub { 0 },
+    'Watcher != "not at exist"'  => sub { 1 },
+# TODO:
+#    'Watcher IS NULL'         => sub { $_[0] eq 'r:-;c:-;' },
+#    'Watcher IS NOT NULL'     => sub { $_[0] ne 'r:-;c:-;' },
+    'Watcher = "x at foo.com"'   => sub { $_[0] =~ /x/ },
+#    'Watcher != "x at foo.com"'  => sub { $_[0] !~ /x/ },
+    'Watcher LIKE "@bar.com"' => sub { $_[0] =~ /(?:y|z)/ },
+# TODO:
+#    'Watcher NOT LIKE "@bar.com"' => sub { $_[0] !~ /y|z/ },
+
+    'Subject LIKE "ne"'      => sub { 0 },
+    'Subject NOT LIKE "ne"'  => sub { 1 },
+    'Subject = "r:x;c:y;"'   => sub { $_[0] eq 'r:x;c:y;' },
+    'Subject LIKE "x"'       => sub { $_[0] =~ 'x' },
 );
-%test = (
-    'Cc = "x at example.com" AND Requestor = "y at example.com"' =>
-        { xy => 1, 'x-' => 0, '-y' => 0, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 },
-    'Cc = "x at example.com" OR Requestor = "y at example.com"' =>
-        { xy => 1, 'x-' => 1, '-y' => 1, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 },
-
-    'Cc != "x at example.com" AND Requestor = "y at example.com"' =>
-        { xy => 0, 'x-' => 0, '-y' => 1, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 },
-    'Cc != "x at example.com" OR Requestor = "y at example.com"' =>
-        { xy => 1, 'x-' => 0, '-y' => 1, '-' => 1, zz => 1, 'z-' => 1, '-z' => 1 },
-
-    'Cc IS NULL AND Requestor = "y at example.com"' =>
-        { xy => 0, 'x-' => 0, '-y' => 1, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 },
-    'Cc IS NULL OR Requestor = "y at example.com"' =>
-        { xy => 1, 'x-' => 0, '-y' => 1, '-' => 1, zz => 0, 'z-' => 0, '-z' => 1 },
-
-    'Cc IS NOT NULL AND Requestor = "y at example.com"' =>
-        { xy => 1, 'x-' => 0, '-y' => 0, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 },
-    'Cc IS NOT NULL OR Requestor = "y at example.com"' =>
-        { xy => 1, 'x-' => 1, '-y' => 1, '-' => 0, zz => 1, 'z-' => 1, '-z' => 0 },
-);
- at tickets = add_tix_from_data();
+
+ at tickets = generate_tix();
 {
     my $tix = RT::Tickets->new($RT::SystemUser);
     $tix->FromSQL("Queue = '$queue'");
     is($tix->Count, $total, "found $total tickets");
 }
-run_tests();
-
+run_auto_tests();
 
 # owner is special watcher because reference is duplicated in two places,
 # owner was an ENUM field now it's WATCHERFIELD, but should support old
@@ -253,7 +261,7 @@ my $nobody = RT::Nobody();
     ok($id, "granted OwnTicket right to Everyone on '$queue'") or diag("error: $msg");
 
     my $u = RT::User->new( $RT::SystemUser );
-    $u->LoadOrCreateByEmail('alpha at example.com');
+    $u->LoadOrCreateByEmail('alpha at e.com');
     ok($u->id, "loaded user");
     @data = ( { Subject => '4', Owner => $u->id } );
     my($t) = add_tix_from_data();
@@ -261,7 +269,7 @@ my $nobody = RT::Nobody();
     my $u_alpha_id = $u->id;
 
     $u = RT::User->new( $RT::SystemUser );
-    $u->LoadOrCreateByEmail('bravo at example.com');
+    $u->LoadOrCreateByEmail('bravo at e.com');
     ok($u->id, "loaded user");
     @data = ( { Subject => '5', Owner => $u->id } );
     ($t) = add_tix_from_data();

commit cdae5ea2494777e1e087aa2ae5fd01e90d4a813d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 17 06:11:52 2010 +0400

    if type is not psecified then we want new join

diff --git a/lib/RT/Tickets_Overlay.pm b/lib/RT/Tickets_Overlay.pm
index c0abf44..901cc2a 100755
--- a/lib/RT/Tickets_Overlay.pm
+++ b/lib/RT/Tickets_Overlay.pm
@@ -832,7 +832,7 @@ sub _WatcherLimit {
     }
     $rest{SUBKEY} ||= 'EmailAddress';
 
-    my $groups = $self->_RoleGroupsJoin( Type => $type, Class => $class );
+    my $groups = $self->_RoleGroupsJoin( Type => $type, Class => $class, New => !$type );
 
     $self->_OpenParen;
     if ( $op =~ /^IS(?: NOT)?$/ ) {

commit f77202f6a06ebdec8fa30dae9271dfe81f728998
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 17 06:13:02 2010 +0400

    fix Requestor = 'not-exist' OR Subject LIKE 'x'

diff --git a/lib/RT/Tickets_Overlay.pm b/lib/RT/Tickets_Overlay.pm
index 901cc2a..3edd2c3 100755
--- a/lib/RT/Tickets_Overlay.pm
+++ b/lib/RT/Tickets_Overlay.pm
@@ -921,49 +921,26 @@ sub _WatcherLimit {
             );
         }
     } else {
+        # positive condition case
+
         my $group_members = $self->_GroupMembersJoin(
-            GroupsAlias => $groups,
-            New => 0,
+            GroupsAlias => $groups, New => 1, Left => 0
         );
-
-        my $users = $self->{'_sql_u_watchers_aliases'}{$group_members};
-        unless ( $users ) {
-            $users = $self->{'_sql_u_watchers_aliases'}{$group_members} = 
-                $self->NewAlias('Users');
-            $self->SUPER::Limit(
-                LEFTJOIN      => $group_members,
-                ALIAS         => $group_members,
-                FIELD         => 'MemberId',
-                VALUE         => "$users.id",
-                QUOTEVALUE    => 0,
-            );
-        }
-
-        # we join users table without adding some join condition between tables,
-        # the only conditions we have are conditions on the table iteslf,
-        # for example Users.EmailAddress = 'x'. We should add this condition to
-        # the top level of the query and bundle it with another similar conditions,
-        # for example "Users.EmailAddress = 'x' OR Users.EmailAddress = 'Y'".
-        # To achive this goal we use own SUBCLAUSE for conditions on the users table.
-        $self->SUPER::Limit(
+        my $users = $self->Join(
+            TYPE            => 'LEFT',
+            ALIAS1          => $group_members,
+            FIELD1          => 'MemberId',
+            TABLE2          => 'Users',
+            FIELD2          => 'id',
+        );
+        $self->_SQLLimit(
             %rest,
-            SUBCLAUSE       => '_sql_u_watchers_'. $users,
             ALIAS           => $users,
             FIELD           => $rest{'SUBKEY'},
             VALUE           => $value,
             OPERATOR        => $op,
             CASESENSITIVE   => 0,
         );
-        # A condition which ties Users and Groups (role groups) is a left join condition
-        # of CachedGroupMembers table. To get correct results of the query we check
-        # if there are matches in CGM table or not using 'cgm.id IS NOT NULL'.
-        $self->_SQLLimit(
-            %rest,
-            ALIAS           => $group_members,
-            FIELD           => 'id',
-            OPERATOR        => 'IS NOT',
-            VALUE           => 'NULL',
-        );
     }
     $self->_CloseParen;
 }

commit dce7a18ca8839dece0101b2e4c44613c8c0afc8b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 17 06:14:02 2010 +0400

    Allow to pick left or inner in _GroupMembersJoin

diff --git a/lib/RT/Tickets_Overlay.pm b/lib/RT/Tickets_Overlay.pm
index 3edd2c3..e2606ca 100755
--- a/lib/RT/Tickets_Overlay.pm
+++ b/lib/RT/Tickets_Overlay.pm
@@ -981,14 +981,14 @@ sub _RoleGroupsJoin {
 
 sub _GroupMembersJoin {
     my $self = shift;
-    my %args = (New => 1, GroupsAlias => undef, @_);
+    my %args = (New => 1, GroupsAlias => undef, Left => 1, @_);
 
     return $self->{'_sql_group_members_aliases'}{ $args{'GroupsAlias'} }
         if $self->{'_sql_group_members_aliases'}{ $args{'GroupsAlias'} }
             && !$args{'New'};
 
     my $alias = $self->Join(
-        TYPE            => 'LEFT',
+        $args{'Left'} ? (TYPE            => 'LEFT') : (),
         ALIAS1          => $args{'GroupsAlias'},
         FIELD1          => 'id',
         TABLE2          => 'CachedGroupMembers',

commit 783861005075680981d55a5f60e074d69f61440f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 17 06:14:53 2010 +0400

    comments

diff --git a/lib/RT/Tickets_Overlay.pm b/lib/RT/Tickets_Overlay.pm
index e2606ca..02b251f 100755
--- a/lib/RT/Tickets_Overlay.pm
+++ b/lib/RT/Tickets_Overlay.pm
@@ -836,6 +836,8 @@ sub _WatcherLimit {
 
     $self->_OpenParen;
     if ( $op =~ /^IS(?: NOT)?$/ ) {
+        # is [not] empty case
+
         my $group_members = $self->_GroupMembersJoin( GroupsAlias => $groups );
         # to avoid joining the table Users into the query, we just join GM
         # and make sure we don't match records where group is member of itself
@@ -855,6 +857,8 @@ sub _WatcherLimit {
         );
     }
     elsif ( $op =~ /^!=$|^NOT\s+/i ) {
+        # negative condition case
+
         # reverse op
         $op =~ s/!|NOT\s+//i;
 

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


More information about the Rt-commit mailing list