[Rt-commit] rt branch, 4.2/use-in-operator, repushed
Alex Vandiver
alexmv at bestpractical.com
Wed Oct 1 14:10:12 EDT 2014
The branch 4.2/use-in-operator was deleted and repushed:
was 47d876236b6a3cb7dc5b7e6cffb68a8ef18f8c87
now 5a73f64788bfe3db6384ca9db13db9d435160abf
1: 3ed8f4b ! 1: 5a73f64 When possible, switch to IN or NOT IN rather than multiple OR'd clauses
@@ -5,9 +5,17 @@
DBIx::SearchBuilder 1.63 began allowing the IN and NOT IN operators; RT
4.0 could not immediately make use of them because it did depend on a
high enough version of DBIx::SearchBuilder. RT 4.2, however, depends on
- DBIx::SearchBuilder 1.65, and thus can use IN freely. Do so, as query
- optimizers are likely to be able to make better plans based on IN
- queries, rather than multiple OR's.
+ DBIx::SearchBuilder 1.65, and thus can use IN freely; this is
+ advantagous because query planners can make better choices with IN than
+ with long boolean queries.
+
+ Unfortunately, DBIx::SearchBuilder 1.65 does not respect the
+ CASESENSITIVE => 0 option when passed OPERATOR => 'IN'. This is only an
+ issue on the limits for Group.Name, which must be case-insensitive. To
+ work around this, pass FUNCTION => 'LOWER(?)', CASESENSITIVE => 1. The
+ former deals with making the search case-insensitive, while the latter
+ quiets the warnings which attempt ot detect case-sensitive searches on
+ Group.Name.
This also rewrites two queries in GetForwardAttachments into one, using
a simple JOIN.
@@ -64,9 +72,10 @@
- }
+ $self->Limit(
+ FIELD => 'Name',
++ FUNCTION => 'LOWER(?)',
+ OPERATOR => 'IN',
+ VALUE => $list,
-+ CASESENSITIVE => 0,
++ CASESENSITIVE => 1,
+ );
} else {
my @list = map {@$_} grep defined && ref($_) eq 'ARRAY',
@@ -85,9 +94,10 @@
+ $self->Limit(
+ FIELD => 'Name',
++ FUNCTION => 'LOWER(?)',
+ OPERATOR => 'NOT IN',
+ VALUE => [ @list ],
-+ CASESENSITIVE => 0,
++ CASESENSITIVE => 1,
+ );
}
return;
@@ -115,7 +125,6 @@
+ FIELD => 'Type',
+ OPERATOR => 'IN',
+ VALUE => [ qw(Create Correspond) ],
-+ CASESENSITIVE => 1,
+ );
}
return $attachments;
@@ -132,9 +141,10 @@
- for $class->Roles;
+ $roles->Limit(
+ FIELD => "Name",
++ FUNCTION => 'LOWER(?)',
+ OPERATOR => "IN",
+ VALUE => [ $class->Roles ],
-+ CASESENSITIVE => 0
++ CASESENSITIVE => 1,
+ );
} else {
# No roles to show; so show nothing
@@ -155,6 +165,20 @@
$self->PushObj( $cfs );
# Global attributes
+
+diff --git a/lib/RT/SearchBuilder/AddAndSort.pm b/lib/RT/SearchBuilder/AddAndSort.pm
+--- a/lib/RT/SearchBuilder/AddAndSort.pm
++++ b/lib/RT/SearchBuilder/AddAndSort.pm
+@@
+ ALIAS => $alias,
+ FIELD => 'ObjectId',
+ OPERATOR => 'IN',
+- QUOTEVALUE => 0,
+- VALUE => "(". join( ',', map $dbh->quote($_), @ids ) .")",
++ VALUE => [ @ids ],
+ );
+
+ return $alias;
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
--- a/lib/RT/Ticket.pm
@@ -178,7 +202,6 @@
+ FIELD => 'Type',
+ OPERATOR => 'IN',
+ VALUE => [ qw(Create Comment Correspond) ],
-+ CASESENSITIVE => 1,
+ );
while ( my $att = $attachments->Next ) {
@@ -244,9 +267,10 @@
- }
+ $groups->Limit(
+ FIELD => 'Name',
++ FUNCTION => 'LOWER(?)',
+ OPERATOR => 'IN',
+ VALUE => [ @tmp ],
-+ CASESENSITIVE => 0
++ CASESENSITIVE => 1,
+ );
my $principal_alias = $groups->Join(
ALIAS1 => 'main',
@@ -309,7 +333,6 @@
+ FIELD => 'GroupId',
+ OPERATOR => 'IN',
+ VALUE => $args{'Groups'},
-+ QUOTEVALUE => 0,
+ );
}
@@ -326,4 +349,3 @@
if ( RT->Config->Get('DatabaseType') eq 'Oracle' ) {
$self->Limit(
-
2: 47d8762 < -: ------- TODO: Fix CASESENSITIVE => 0 with OPERATOR => 'IN'
More information about the rt-commit
mailing list