[Rt-commit] rt branch, 4.2/date-is-null, created. rt-4.2.1-65-g51aadc9

Alex Vandiver alexmv at bestpractical.com
Fri Jan 3 20:07:07 EST 2014


The branch, 4.2/date-is-null has been created
        at  51aadc960f01dcc828d595d25cff0cf190cafa0e (commit)

- Log -----------------------------------------------------------------
commit b874550cc4d09afe9960f100bc57ae398d646798
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Dec 24 12:21:25 2013 -0500

    Allow searching for dates which are unset
    
    e60885aa changed the meaning of "Starts < 'today'" (and all other date
    limits) to no longer include tickets whose dates are unset.  This
    behavior change also made it imposible to search for such tickets, as
    "Starts = '1970-01-01'" would also no longer find them, and the more
    straightforward "Starts IS NULL" was invalid.
    
    Allow IS NULL and IS NOT NULL searches on date ranges.

diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 0f3308e..8888059 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -553,12 +553,22 @@ sub _DateLimit {
     my ( $sb, $field, $op, $value, %rest ) = @_;
 
     die "Invalid Date Op: $op"
-        unless $op =~ /^(=|>|<|>=|<=)$/;
+        unless $op =~ /^(=|>|<|>=|<=|IS(\s+NOT)?)$/i;
 
     my $meta = $FIELD_METADATA{$field};
     die "Incorrect Meta Data for $field"
         unless ( defined $meta->[1] );
 
+    if ( $op =~ /^(IS(\s+NOT)?)$/i) {
+        return $sb->Limit(
+            FUNCTION => $sb->NotSetDateToNullFunction,
+            FIELD    => $meta->[1],
+            OPERATOR => $op,
+            VALUE    => "NULL",
+            %rest,
+        );
+    }
+
     if ( my $subkey = $rest{SUBKEY} ) {
         if ( $subkey eq 'DayOfWeek' && $op !~ /IS/i && $value =~ /[^0-9]/ ) {
             for ( my $i = 0; $i < @RT::Date::DAYS_OF_WEEK; $i++ ) {

commit 00903d89dd37d4f01761f6a8a8f1d2b6b0304978
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Dec 24 12:26:43 2013 -0500

    Add an UPGRADING note about the changed meaning of < in date limits

diff --git a/docs/UPGRADING-4.2 b/docs/UPGRADING-4.2
index 0e458fa..dd21c25 100644
--- a/docs/UPGRADING-4.2
+++ b/docs/UPGRADING-4.2
@@ -300,6 +300,14 @@ on C<configure> enabling these in F<RT_Config.pm> implicitly will need
 to pass C<--enable-gpg> to C<configure>, or alter their
 C<RT_SiteConfig.pm> to enable the functionality explicitly.
 
+=item *
+
+In TicketSQL, "Starts = '1970-01-01'" will no longer find tickets with
+no Starts date set.  Instead, use "Starts IS NULL".  As a direct
+consequence, "Starts < 'today'" will no longer also find tickets with no
+Starts date; use "Starts < 'today' OR Starts IS NULL" to have the
+equivalent results in RT 4.2.
+
 =back
 
 =cut

commit f8ccfdf3fd735192beb1d90790dc77735aced719
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Jan 3 16:19:09 2014 -0500

    Add some simple tests for IS and IS NOT NULL

diff --git a/t/api/tickets.t b/t/api/tickets.t
index 50d08f7..c2ddb79 100644
--- a/t/api/tickets.t
+++ b/t/api/tickets.t
@@ -2,8 +2,7 @@
 use strict;
 use warnings;
 use RT;
-use RT::Test tests => 18;
-
+use RT::Test tests => undef;
 
 {
 
@@ -114,3 +113,26 @@ ok( $unlimittickets->Count > 0, "UnLimited tickets object should return tickets"
     ok $count == 1, "found one ticket";
 }
 
+{
+    my $tickets = RT::Tickets->new( RT->SystemUser );
+    my ($ret, $msg) = $tickets->FromSQL("Resolved IS NULL");
+    ok $ret, "Ran query with IS NULL: $msg";
+    my $count = $tickets->Count();
+    ok $count > 1, "Found more than one ticket";
+    undef $count;
+}
+
+{
+    my $ticket = RT::Ticket->new( RT->SystemUser );
+    ok $ticket->Load(1), "Loaded test ticket 1";
+    ok $ticket->SetStatus('resolved'), "Set to resolved";
+
+    my $tickets = RT::Tickets->new( RT->SystemUser );
+    my ($ret, $msg) = $tickets->FromSQL("Resolved IS NOT NULL");
+    ok $ret, "Ran query with IS NOT NULL: $msg";
+    my $count = $tickets->Count();
+    ok $count == 1, "Found one ticket";
+    undef $count;
+}
+
+done_testing;

commit 51aadc960f01dcc828d595d25cff0cf190cafa0e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Jan 3 18:51:50 2014 -0500

    Allow IS/IS NOT with LimitDate, by providing DefaultEA for them
    
    %DefaultEA only matters for the old Restrictions clauses; regardless,
    permit the new format there, for consistency.

diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 8888059..49524bc 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -202,6 +202,8 @@ my %DefaultEA = (
         '!=' => 'AND'
     },
     DATE => {
+        'IS' => 'OR',
+        'IS NOT' => 'OR',
         '='  => 'OR',
         '>=' => 'AND',
         '<=' => 'AND',
diff --git a/t/api/tickets.t b/t/api/tickets.t
index c2ddb79..172965c 100644
--- a/t/api/tickets.t
+++ b/t/api/tickets.t
@@ -135,4 +135,13 @@ ok( $unlimittickets->Count > 0, "UnLimited tickets object should return tickets"
     undef $count;
 }
 
+{
+    my $tickets = RT::Tickets->new( RT->SystemUser );
+    $tickets->LimitDate( FIELD => "Resolved", OPERATOR => "IS",     VALUE => "NULL" );
+    $tickets->LimitDate( FIELD => "Resolved", OPERATOR => "IS NOT", VALUE => "NULL" );
+    my $count = $tickets->Count();
+    ok $count > 1, "Found more than one ticket";
+    undef $count;
+}
+
 done_testing;

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


More information about the rt-commit mailing list