[Rt-commit] r2738 - in rt/branches/3.4-RELEASE: . lib/RT
lib/t/regression sbin
jesse at bestpractical.com
jesse at bestpractical.com
Sun Apr 17 20:26:16 EDT 2005
Author: jesse
Date: Sun Apr 17 20:26:15 2005
New Revision: 2738
Modified:
rt/branches/3.4-RELEASE/ (props changed)
rt/branches/3.4-RELEASE/lib/RT/Tickets_Overlay.pm
rt/branches/3.4-RELEASE/lib/t/regression/12-search.t
rt/branches/3.4-RELEASE/sbin/rt-test-dependencies.in
Log:
r13186 at hualien: jesse | 2005-04-17 20:24:41 -0400
RT-Ticket: 6562
RT-Status: resolved
RT-Update: correspond
* Patch from Tom Yu to allow negative CF searching and better
multi-CF search.
* Bumped SearchBuilder dependency to new version
Modified: rt/branches/3.4-RELEASE/lib/RT/Tickets_Overlay.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Tickets_Overlay.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Tickets_Overlay.pm Sun Apr 17 20:26:15 2005
@@ -1081,13 +1081,15 @@
$field = $1 if $field =~ /^{(.+)}$/; # trim { }
-# If we're trying to find custom fields that don't match something, we want tickets
-# where the custom field has no value at all
+# If we're trying to find custom fields that don't match something, we
+# want tickets where the custom field has no value at all. Note that
+# we explicitly don't include the "IS NULL" case, since we would
+# otherwise end up with a redundant clause.
my $null_columns_ok;
- if ( ( $op =~ /^IS$/i ) or ( $op =~ /^NOT LIKE$/i ) or ( $op eq '!=' ) ) {
+ if ( ( $op =~ /^NOT LIKE$/i ) or ( $op eq '!=' ) ) {
$null_columns_ok = 1;
- }
+ }
my $cfid = 0;
if ($queue) {
@@ -1106,24 +1108,53 @@
$cfid = $cf->id;
- } else { # if we have no id, we're going to search on name.
- $cfid = $field;
}
my $TicketCFs;
+ my $cfkey = $cfid ? $cfid : "$queue.$field";
# Perform one Join per CustomField
- if ( $self->{_sql_object_cf_alias}{$cfid} ) {
- $TicketCFs = $self->{_sql_object_cf_alias}{$cfid};
+ if ( $self->{_sql_object_cf_alias}{$cfkey} ) {
+ $TicketCFs = $self->{_sql_object_cf_alias}{$cfkey};
}
else {
- $TicketCFs = $self->{_sql_object_cf_alias}{$cfid} = $self->Join(
- TYPE => 'left',
- ALIAS1 => 'main',
- FIELD1 => 'id',
- TABLE2 => 'ObjectCustomFieldValues',
- FIELD2 => 'ObjectId'
- );
+ if ($cfid) {
+ $TicketCFs = $self->{_sql_object_cf_alias}{$cfkey} = $self->Join(
+ TYPE => 'left',
+ ALIAS1 => 'main',
+ FIELD1 => 'id',
+ TABLE2 => 'ObjectCustomFieldValues',
+ FIELD2 => 'ObjectId',
+ );
+ $self->SUPER::Limit(
+ LEFTJOIN => $TicketCFs,
+ FIELD => 'CustomField',
+ VALUE => $cfid,
+ ENTRYAGGREGATOR => 'AND'
+ );
+ } else {
+ my $cfalias = $self->Join(
+ TYPE => 'left',
+ EXPRESSION => "'$field'",
+ TABLE2 => 'CustomFields',
+ FIELD2 => 'Name',
+ );
+
+ $TicketCFs = $self->{_sql_object_cf_alias}{$cfkey} = $self->Join(
+ TYPE => 'left',
+ ALIAS1 => $cfalias,
+ FIELD1 => 'id',
+ TABLE2 => 'ObjectCustomFieldValues',
+ FIELD2 => 'CustomField',
+ );
+ $self->SUPER::Limit(
+ LEFTJOIN => $TicketCFs,
+ FIELD => 'ObjectId',
+ VALUE => 'main.id',
+ QUOTEVALUE => 0,
+ ENTRYAGGREGATOR => 'AND',
+ );
+ }
$self->SUPER::Limit(
LEFTJOIN => $TicketCFs,
FIELD => 'ObjectType',
@@ -1137,30 +1168,6 @@
OPERATOR => '=',
VALUE => '0',
ENTRYAGGREGATOR => 'AND');
-
- if ($cfid =~ /^\d+$/) { # we have a numerical cfid. we know which cf we want
- $self->SUPER::Limit(
- LEFTJOIN => $TicketCFs,
- FIELD => 'CustomField',
- VALUE => $cfid,
- ENTRYAGGREGATOR => 'AND'
- );
- }
- else { # we're going to need to search on cf name
- my $cfalias = $self->Join(
- ALIAS1 => $TicketCFs,
- TYPE => 'left',
- FIELD1 => 'CustomField',
- TABLE2 => 'CustomFields',
- FIELD2 => 'id'
- );
- $self->SUPER::Limit(
- LEFTJOIN => $cfalias,
- FIELD => 'Name',
- VALUE => $field,
- );
-
- }
}
$self->_OpenParen if ($null_columns_ok);
@@ -1173,7 +1180,8 @@
QUOTEVALUE => 1,
@rest
);
- if ($null_columns_ok && ($op ne 'IS' && $value ne 'NULL')) {
+
+ if ($null_columns_ok) {
$self->_SQLLimit(
ALIAS => $TicketCFs,
FIELD => 'Content',
Modified: rt/branches/3.4-RELEASE/lib/t/regression/12-search.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/12-search.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/12-search.t Sun Apr 17 20:26:15 2005
@@ -145,17 +145,11 @@
$tix->FromSQL("Queue = '$queue' AND CF.SearchTest LIKE 'foo'");
is($tix->Count, 5, "matched LIKE subject");
-#$tix = RT::Tickets->new($RT::SystemUser);
-#$tix->FromSQL("Queue = '$queue' AND CF.SearchTest IS NULL");
-#is($tix->Count, 2, "LIKE null CF");
$tix = RT::Tickets->new($RT::SystemUser);
$tix->FromSQL("Queue = '$queue' AND CF.SearchTest IS NULL");
-SKIP: {
- skip "Negative CF searches don't work", 1;
- is($tix->Count, 2, "IS null CF");};
-
+ is($tix->Count, 2, "IS null CF");
$tix = RT::Tickets->new($RT::SystemUser);
$tix->FromSQL("Queue = '$queue' AND Requestors LIKE 'search1'");
@@ -169,9 +163,14 @@
$tix->FromSQL("Queue = '$queue' AND Requestors LIKE 'search'");
is($tix->Count, 6, "LIKE requestor");
-$tix = RT::Tickets->new($RT::SystemUser);
-$tix->FromSQL("Queue = '$queue' AND Requestors IS NULL");
-SKIP {skip "Can't search for 'no requestor", 1; is($tix->Count, 1, "Search for no requestor")};
+TODO: {
+
+ local $TODO = "Can't search for 'no requestor";
+ $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Requestors IS NULL");
+ is($tix->Count, 1, "Search for no requestor");
+
+};
$tix = RT::Tickets->new($RT::SystemUser);
$tix->FromSQL("Queue = '$queue' AND Subject = 'SearchTest1'");
@@ -223,19 +222,14 @@
is($tix->Count, 4, "like cf and like subject");
$tix = RT::Tickets->new($RT::SystemUser);
-$tix->FromSQL("CF.SearchTest IS NULL AND CF.SearchTest2 = 'bar5'");
-SKIP: {
+$tix->FromSQL("CF.SearchTest IS NULL AND CF.SearchTest2 = 'bar2'");
- skip "Negative CF searches don't work", 1;
- is($tix->Count, 1, "null cf and is cf"); };
-
+ is($tix->Count, 1, "null cf and is cf");
$tix = RT::Tickets->new($RT::SystemUser);
-$tix->FromSQL("Queue = '$$' AND CF.SearchTest IS NULL AND CF.SearchTest2 IS NULL");
-SKIP: {
- skip "Negative CF searches don't work", 1;
+$tix->FromSQL("Queue = '$queue' AND CF.SearchTest IS NULL AND CF.SearchTest2 IS NULL");
- is($tix->Count, 1, "null cf and null cf"); };
+ is($tix->Count, 1, "null cf and null cf");
Modified: rt/branches/3.4-RELEASE/sbin/rt-test-dependencies.in
==============================================================================
--- rt/branches/3.4-RELEASE/sbin/rt-test-dependencies.in (original)
+++ rt/branches/3.4-RELEASE/sbin/rt-test-dependencies.in Sun Apr 17 20:26:15 2005
@@ -122,7 +122,7 @@
DBI 1.37
Test::Inline
Class::ReturnValue 0.40
-DBIx::SearchBuilder 1.24
+DBIx::SearchBuilder 1.26
Text::Template
File::Spec 0.8
HTML::Entities
More information about the Rt-commit
mailing list