[Rt-commit] rt branch, 4.2/empty-in-clause, created. rt-4.2.9-52-g36c3098

Alex Vandiver alexmv at bestpractical.com
Wed Dec 10 13:46:42 EST 2014


The branch, 4.2/empty-in-clause has been created
        at  36c30985d831c89d4fb74d6e5e763dcff66d9dac (commit)

- Log -----------------------------------------------------------------
commit 36c30985d831c89d4fb74d6e5e763dcff66d9dac
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Dec 10 13:45:09 2014 -0500

    Ensure that all IN limits are called with at least one element
    
    Limiting to IN with an empty arrayref generates the invalid SQL
    "main.SomeField IN ()"; this was introduced most notably in 13ce5b02,
    for charts with no results, but also applies to the changes in b14df0ee.
    
    Prevent this by either bailing out before applying the limit (in most
    existing cases), or by ensuring that the limit contains at least a 0,
    making it into a null set.  Whether the situation calls for a no-op
    limit (by bailing out early) or a null-set limit (by adding a 0) depends
    on the context.

diff --git a/lib/RT/Articles.pm b/lib/RT/Articles.pm
index ea82827..43ec5ec 100644
--- a/lib/RT/Articles.pm
+++ b/lib/RT/Articles.pm
@@ -403,6 +403,7 @@ sub LimitCustomField {
 sub LimitTopics {
     my $self   = shift;
     my @topics = @_;
+    return unless @topics;
 
     my $topics = $self->NewAlias('ObjectTopics');
     $self->Limit(
diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index a44512e..d7abe94 100644
--- a/lib/RT/Report/Tickets.pm
+++ b/lib/RT/Report/Tickets.pm
@@ -477,7 +477,7 @@ sub SetupGroupings {
         # If it isn't, we need to do this in two stages -- first, find
         # the distinct matching tickets (with no group by), then search
         # within the matching tickets grouped by what is wanted.
-        my @match;
+        my @match = (0);
         $self->Columns( 'id' );
         while (my $row = $self->Next) {
             push @match, $row->id;
diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
index 8517036..54bb71e 100644
--- a/lib/RT/Users.pm
+++ b/lib/RT/Users.pm
@@ -574,7 +574,7 @@ sub WhoBelongToGroups {
         ALIAS      => $group_members,
         FIELD      => 'GroupId',
         OPERATOR   => 'IN',
-        VALUE      => $args{'Groups'},
+        VALUE      => [ 0, @{$args{'Groups'}} ],
     );
 }
 

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


More information about the rt-commit mailing list