[Rt-commit] rt branch, cf-date, updated. rt-3.8.8-188-gee1b9a2

? sunnavy sunnavy at bestpractical.com
Tue Jul 27 20:58:45 EDT 2010


The branch, cf-date has been updated
       via  ee1b9a2a0e1156de21876a7ce3b8f84a8a84392f (commit)
      from  3f8e512c4bbda28958261541f88fc77042f3f7ea (commit)

Summary of changes:
 lib/RT/Tickets_Overlay.pm |  191 ++++++++++++++++++++++++---------------------
 1 files changed, 102 insertions(+), 89 deletions(-)

- Log -----------------------------------------------------------------
commit ee1b9a2a0e1156de21876a7ce3b8f84a8a84392f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jul 28 08:59:16 2010 +0800

    customize < and > ops for cf date too, as normal ones will expload in Oracle

diff --git a/lib/RT/Tickets_Overlay.pm b/lib/RT/Tickets_Overlay.pm
index 9bc069b..60e3e6a 100755
--- a/lib/RT/Tickets_Overlay.pm
+++ b/lib/RT/Tickets_Overlay.pm
@@ -1423,44 +1423,57 @@ sub _CustomFieldLimit {
                 %rest
             );
         }
-        elsif ( $op eq '=' || $op eq '!=' || $op eq '<>' ) {
+        else {
             my $cf = RT::CustomField->new( $self->CurrentUser );
             $cf->Load($field);
-            if ( $op eq '=' && $cf->Type eq 'Date' ) {
+
+            # need special treatment for Date
+            if ( $cf->Type eq 'Date' ) {
+                if ( $op eq '=' ) {
 
                # if we're specifying =, that means we want everything on a
                # particular single day.  in the database, we need to check for >
                # and < the edges of that day.
 
-                my $date = RT::Date->new( $self->CurrentUser );
-                $date->Set( Format => 'unknown', Value => $value );
-                $date->SetToMidnight( Timezone => 'server' );
-                my $daystart = $date->ISO;
-                $date->AddDay;
-                my $dayend = $date->ISO;
+                    my $date = RT::Date->new( $self->CurrentUser );
+                    $date->Set( Format => 'unknown', Value => $value );
+                    $date->SetToMidnight( Timezone => 'server' );
+                    my $daystart = $date->ISO;
+                    $date->AddDay;
+                    my $dayend = $date->ISO;
 
-                $self->_OpenParen;
+                    $self->_OpenParen;
 
-                $self->_SQLLimit(
-                    ALIAS    => $TicketCFs,
-                    FIELD    => 'Content',
-                    OPERATOR => ">=",
-                    VALUE    => $daystart,
-                    %rest,
-                );
+                    $self->_SQLLimit(
+                        ALIAS    => $TicketCFs,
+                        FIELD    => 'Content',
+                        OPERATOR => ">=",
+                        VALUE    => $daystart,
+                        %rest,
+                    );
 
-                $self->_SQLLimit(
-                    ALIAS    => $TicketCFs,
-                    FIELD    => 'Content',
-                    OPERATOR => "<=",
-                    VALUE    => $dayend,
-                    %rest,
-                    ENTRYAGGREGATOR => 'AND',
-                );
+                    $self->_SQLLimit(
+                        ALIAS    => $TicketCFs,
+                        FIELD    => 'Content',
+                        OPERATOR => "<=",
+                        VALUE    => $dayend,
+                        %rest,
+                        ENTRYAGGREGATOR => 'AND',
+                    );
 
-                $self->_CloseParen;
+                    $self->_CloseParen;
+                }
+                else {
+                    $self->_SQLLimit(
+                        ALIAS    => $TicketCFs,
+                        FIELD    => 'Content',
+                        OPERATOR => $op,
+                        VALUE    => $value,
+                        %rest,
+                    );
+                }
             }
-            else {
+            elsif ( $op eq '=' || $op eq '!=' || $op eq '<>' ) {
                 unless ( length( Encode::encode_utf8($value) ) > 255 ) {
                     $self->_SQLLimit(
                         ALIAS    => $TicketCFs,
@@ -1496,77 +1509,77 @@ sub _CustomFieldLimit {
                     );
                 }
             }
-        }
-        else {
-            $self->_SQLLimit(
-                ALIAS      => $TicketCFs,
-                FIELD      => 'Content',
-                OPERATOR   => $op,
-                VALUE      => $value,
-                %rest
-            );
+            else {
+                $self->_SQLLimit(
+                    ALIAS    => $TicketCFs,
+                    FIELD    => 'Content',
+                    OPERATOR => $op,
+                    VALUE    => $value,
+                    %rest
+                );
 
-            $self->_OpenParen;
-            $self->_OpenParen;
-            $self->_SQLLimit(
-                ALIAS      => $TicketCFs,
-                FIELD      => 'Content',
-                OPERATOR   => '=',
-                VALUE      => '',
-                ENTRYAGGREGATOR => 'OR'
-            );
-            $self->_SQLLimit(
-                ALIAS      => $TicketCFs,
-                FIELD      => 'Content',
-                OPERATOR   => 'IS',
-                VALUE      => 'NULL',
-                ENTRYAGGREGATOR => 'OR'
-            );
+                $self->_OpenParen;
+                $self->_OpenParen;
+                $self->_SQLLimit(
+                    ALIAS           => $TicketCFs,
+                    FIELD           => 'Content',
+                    OPERATOR        => '=',
+                    VALUE           => '',
+                    ENTRYAGGREGATOR => 'OR'
+                );
+                $self->_SQLLimit(
+                    ALIAS           => $TicketCFs,
+                    FIELD           => 'Content',
+                    OPERATOR        => 'IS',
+                    VALUE           => 'NULL',
+                    ENTRYAGGREGATOR => 'OR'
+                );
+                $self->_CloseParen;
+                $self->_SQLLimit(
+                    ALIAS           => $TicketCFs,
+                    FIELD           => 'LargeContent',
+                    OPERATOR        => $fix_op->($op),
+                    VALUE           => $value,
+                    ENTRYAGGREGATOR => 'AND',
+                );
+                $self->_CloseParen;
+            }
             $self->_CloseParen;
+
+            # XXX: if we join via CustomFields table then
+            # because of order of left joins we get NULLs in
+            # CF table and then get nulls for those records
+            # in OCFVs table what result in wrong results
+            # as decifer method now tries to load a CF then
+            # we fall into this situation only when there
+            # are more than one CF with the name in the DB.
+            # the same thing applies to order by call.
+            # TODO: reorder joins T <- OCFVs <- CFs <- OCFs if
+            # we want treat IS NULL as (not applies or has
+            # no value)
             $self->_SQLLimit(
-                ALIAS => $TicketCFs,
-                FIELD => 'LargeContent',
-                OPERATOR => $fix_op->($op),
-                VALUE => $value,
+                ALIAS           => $CFs,
+                FIELD           => 'Name',
+                OPERATOR        => 'IS NOT',
+                VALUE           => 'NULL',
+                QUOTEVALUE      => 0,
                 ENTRYAGGREGATOR => 'AND',
-            );
+            ) if $CFs;
             $self->_CloseParen;
-        }
-        $self->_CloseParen;
 
-        # XXX: if we join via CustomFields table then
-        # because of order of left joins we get NULLs in
-        # CF table and then get nulls for those records
-        # in OCFVs table what result in wrong results
-        # as decifer method now tries to load a CF then
-        # we fall into this situation only when there
-        # are more than one CF with the name in the DB.
-        # the same thing applies to order by call.
-        # TODO: reorder joins T <- OCFVs <- CFs <- OCFs if
-        # we want treat IS NULL as (not applies or has
-        # no value)
-        $self->_SQLLimit(
-            ALIAS      => $CFs,
-            FIELD      => 'Name',
-            OPERATOR   => 'IS NOT',
-            VALUE      => 'NULL',
-            QUOTEVALUE => 0,
-            ENTRYAGGREGATOR => 'AND',
-        ) if $CFs;
-        $self->_CloseParen;
+            if ($negative_op) {
+                $self->_SQLLimit(
+                    ALIAS           => $TicketCFs,
+                    FIELD           => $column || 'Content',
+                    OPERATOR        => 'IS',
+                    VALUE           => 'NULL',
+                    QUOTEVALUE      => 0,
+                    ENTRYAGGREGATOR => 'OR',
+                );
+            }
 
-        if ($negative_op) {
-            $self->_SQLLimit(
-                ALIAS           => $TicketCFs,
-                FIELD           => $column || 'Content',
-                OPERATOR        => 'IS',
-                VALUE           => 'NULL',
-                QUOTEVALUE      => 0,
-                ENTRYAGGREGATOR => 'OR',
-            );
+            $self->_CloseParen;
         }
-
-        $self->_CloseParen;
     }
     else {
         $cfkey .= '.'. $self->{'_sql_multiple_cfs_index'}++;

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


More information about the Rt-commit mailing list