#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
return %args;
};
+ # Special Limit (we can exit early)
+ # IS NULL and IS NOT NULL checks
+ if ( $op =~ /^IS( NOT)?$/i ) {
+ my ($ocfvalias, $CFs) = $self->_CustomFieldJoin( $cfkey, $cf, $ltype );
+ $self->_OpenParen( $args{SUBCLAUSE} );
+ $self->Limit(
+ %args,
+ ALIAS => $ocfvalias,
+ FIELD => ($column || 'id'),
+ OPERATOR => $op,
+ VALUE => $value,
+ );
+ # See below for an explanation of this limit
+ $self->Limit(
+ ALIAS => $CFs,
+ FIELD => 'Name',
+ OPERATOR => 'IS NOT',
+ VALUE => 'NULL',
+ ENTRYAGGREGATOR => 'AND',
+ SUBCLAUSE => $args{SUBCLAUSE},
+ ) if $CFs;
+ $self->_CloseParen( $args{SUBCLAUSE} );
+ return;
+ }
+
########## Content pre-parsing if we know things about the CF
if ( blessed($cf) and delete $args{PREPARSE} ) {
my $type = $cf->Type;
$RT::Logger->warn("$value is not a valid IPAddress");
}
} elsif ( $type eq 'IPAddressRange' ) {
- if ( $value =~ /^\s*$RE{net}{CIDR}{IPv4}{-keep}\s*$/o ) {
- # convert incomplete 192.168/24 to 192.168.0.0/24 format
- $value =
- join( '.', map $_ || 0, ( split /\./, $1 )[ 0 .. 3 ] ) . "/$2"
- || $value;
- }
-
my ( $start_ip, $end_ip ) =
RT::ObjectCustomFieldValue->ParseIPRange($value);
if ( $start_ip && $end_ip ) {
} elsif ( $type =~ /^Date(?:Time)?$/ ) {
my $date = RT::Date->new( $self->CurrentUser );
$date->Set( Format => 'unknown', Value => $value );
- if ( $date->Unix ) {
+ if ( $date->IsSet ) {
if (
$type eq 'Date'
# Heuristics to determine if a date, and not
}
########## Limits
- # IS NULL and IS NOT NULL checks
- if ( $op =~ /^IS( NOT)?$/i ) {
- my ($ocfvalias, $CFs) = $self->_CustomFieldJoin( $cfkey, $cf, $ltype );
- $self->_OpenParen( $args{SUBCLAUSE} );
- $self->Limit(
- %args,
- ALIAS => $ocfvalias,
- FIELD => ($column || 'id'),
- OPERATOR => $op,
- VALUE => $value,
- );
- # See below for an explanation of this limit
- $self->Limit(
- ALIAS => $CFs,
- FIELD => 'Name',
- OPERATOR => 'IS NOT',
- VALUE => 'NULL',
- ENTRYAGGREGATOR => 'AND',
- SUBCLAUSE => $args{SUBCLAUSE},
- ) if $CFs;
- $self->_CloseParen( $args{SUBCLAUSE} );
- return;
- }
my $single_value = !blessed($cf) || $cf->SingleValue;
my $negative_op = ($op eq '!=' || $op =~ /\bNOT\b/i);
- my $value_is_long = (length( Encode::encode_utf8($value)) > 255) ? 1 : 0;
+ my $value_is_long = (length( Encode::encode( "UTF-8", $value)) > 255) ? 1 : 0;
$cfkey .= '.'. $self->{'_sql_multiple_cfs_index'}++
if not $single_value and $op =~ /^(!?=|(NOT )?LIKE)$/i;