[Rt-commit] rt branch 5.0/improve-text-indexes2 created. rt-5.0.3-330-gb2bf9ebcd9

BPS Git Server git at git.bestpractical.com
Thu Mar 23 22:34:12 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/improve-text-indexes2 has been created
        at  b2bf9ebcd9ca94ce9c0130178084c7163cece2ca (commit)

- Log -----------------------------------------------------------------
commit b2bf9ebcd9ca94ce9c0130178084c7163cece2ca
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 1 00:27:26 2022 +0800

    Update SQL tests as Status and Lifecycle are searched case insensitively now

diff --git a/t/api/sql.t b/t/api/sql.t
index 262a6c2d8b..943e234d53 100644
--- a/t/api/sql.t
+++ b/t/api/sql.t
@@ -28,6 +28,19 @@ RT->Config->Set(
         defaults => { on_create => 'new', },
     },
 );
+my $status_key = RT->DatabaseHandle->CaseSensitive ? 'LOWER\(\w+.Status\)' : 'Status';
+my $lifecycle_key = RT->DatabaseHandle->CaseSensitive ? 'LOWER\(\w+.Lifecycle\)' : 'Lifecycle';
+
+my %ticketsql = (
+    q{Status = 'new' OR Status = 'open'}                => qr{$status_key IN \('new', 'open'\)},
+    q{Status = '__Active__'}                            => qr{$status_key IN \('new', 'open', 'stalled'\)},
+    q{id = 2 OR id = 3}                                 => qr{id IN \('2', '3'\)},
+    q{Creator = 'root' OR Creator = 'alice'}            => qr{Creator IN \('$alice_id', '$root_id'\)},
+    q{Queue = 'General' OR Queue = 'Support'}           => qr{Queue IN \('$general_id', '$support_id'\)},
+    q{Lifecycle = 'default' or Lifecycle = 'approvals'} => qr{$lifecycle_key IN \('approvals', 'default'\)},
+    q{(Queue = 'General' OR Queue = 'Support') AND (Status = 'new' OR Status = 'open')} =>
+        qr{Queue IN \('$general_id', '$support_id'\).+$status_key IN \('new', 'open'\)},
+);
 
 RT::Lifecycle->FillCache();
 
@@ -38,14 +51,14 @@ my $hardware_catalog_id = RT::Test::Assets->load_or_create_catalog( Name => 'Har
 my %sql = (
     'RT::Tickets' => {
         like => {
-            q{Status = 'new' OR Status = 'open'}                => qr{Status IN \('new', 'open'\)},
-            q{Status = '__Active__'}                            => qr{Status IN \('new', 'open', 'stalled'\)},
+            q{Status = 'new' OR Status = 'open'}                => qr{$status_key IN \('new', 'open'\)},
+            q{Status = '__Active__'}                            => qr{$status_key IN \('new', 'open', 'stalled'\)},
             q{id = 2 OR id = 3}                                 => qr{id IN \('2', '3'\)},
             q{Creator = 'root' OR Creator = 'alice'}            => qr{Creator IN \('$alice_id', '$root_id'\)},
             q{Queue = 'General' OR Queue = 'Support'}           => qr{Queue IN \('$general_id', '$support_id'\)},
-            q{Lifecycle = 'default' or Lifecycle = 'approvals'} => qr{Lifecycle IN \('approvals', 'default'\)},
+            q{Lifecycle = 'default' or Lifecycle = 'approvals'} => qr{$lifecycle_key IN \('approvals', 'default'\)},
             q{(Queue = 'General' OR Queue = 'Support') AND (Status = 'new' OR Status = 'open')} =>
-                qr{Queue IN \('$general_id', '$support_id'\).+Status IN \('new', 'open'\)},
+                qr{Queue IN \('$general_id', '$support_id'\).+$status_key IN \('new', 'open'\)},
         },
         unlike => {
             q{Status = '__Active__' and Queue = 'General'}       => qr{approvals},
@@ -54,17 +67,17 @@ my %sql = (
     },
     'RT::Transactions' => {
         like => {
-            q{TicketStatus = 'new' OR TicketStatus = 'open'}      => qr{Status IN \('new', 'open'\)},
-            q{TicketStatus = '__Active__'}                        => qr{Status IN \('new', 'open', 'stalled'\)},
+            q{TicketStatus = 'new' OR TicketStatus = 'open'}      => qr{$status_key IN \('new', 'open'\)},
+            q{TicketStatus = '__Active__'}                        => qr{$status_key IN \('new', 'open', 'stalled'\)},
             q{id = 2 OR id = 3}                                   => qr{id IN \('2', '3'\)},
             q{Creator = 'root' OR Creator = 'alice'}              => qr{Creator IN \('$alice_id', '$root_id'\)},
             q{TicketCreator = 'root' OR TicketCreator = 'alice'}  => qr{Creator IN \('$alice_id', '$root_id'\)},
             q{TicketLastUpdatedBy = 'root' OR TicketLastUpdatedBy = 'alice'}  => qr{LastUpdatedBy IN \('$alice_id', '$root_id'\)},
             q{TicketQueue = 'General' OR TicketQueue = 'Support'} => qr{Queue IN \('$general_id', '$support_id'\)},
             q{TicketQueueLifecycle = 'default' or TicketQueueLifecycle = 'approvals'} =>
-                qr{Lifecycle IN \('approvals', 'default'\)},
+                qr{$lifecycle_key IN \('approvals', 'default'\)},
             q{(TicketQueue = 'General' OR TicketQueue = 'Support') AND (TicketStatus = 'new' OR TicketStatus = 'open')}
-                => qr{Queue IN \('$general_id', '$support_id'\).+Status IN \('new', 'open'\)},
+                => qr{Queue IN \('$general_id', '$support_id'\).+$status_key IN \('new', 'open'\)},
         },
         unlike => {
             q{TicketStatus = '__Active__' and TicketQueue = 'General'} => qr{approvals},
@@ -72,13 +85,13 @@ my %sql = (
     },
     'RT::Assets' => {
         like => {
-            q{Status = 'new' OR Status = 'allocated'}             => qr{Status IN \('allocated', 'new'\)},
-            q{Status = '__Active__'}                              => qr{Status IN \('allocated', 'in-use', 'new'\)},
+            q{Status = 'new' OR Status = 'allocated'}             => qr{$status_key IN \('allocated', 'new'\)},
+            q{Status = '__Active__'}                              => qr{$status_key IN \('allocated', 'in-use', 'new'\)},
             q{id = 2 OR id = 3}                                   => qr{id IN \('2', '3'\)},
             q{Catalog = 'General assets' OR Catalog = 'Hardware'} =>
                 qr{Catalog IN \('$general_catalog_id', '$hardware_catalog_id'\)},
             q{(Catalog = 'General assets' OR Catalog = 'Hardware') AND (Status = 'allocated' OR Status = 'new')} =>
-                qr{Catalog IN \('$general_catalog_id', '$hardware_catalog_id'\).+Status IN \('allocated', 'new'\)},
+                qr{Catalog IN \('$general_catalog_id', '$hardware_catalog_id'\).+$status_key IN \('allocated', 'new'\)},
         },
         unlike => {
             q{Status = '__Active__' and Catalog = 'General assets'} => qr{hardware},

commit ad1114b6e8ef37dd80053a86a4b8ae62dd35af7a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Mar 23 15:53:55 2023 +0800

    Use is_case_sensitive to determine case sensitivity for FromSQL string limits
    
    The SQL for transaction searches is a bit different: Previous all string
    fields like Type, Field, etc. were searched case insensitively, which
    wasn't necessary. Now only OldValue, NewValue and Data are searched that
    way. SQL results should be the same.

diff --git a/lib/RT/Assets.pm b/lib/RT/Assets.pm
index bc9f942073..359cb7c8dc 100644
--- a/lib/RT/Assets.pm
+++ b/lib/RT/Assets.pm
@@ -1217,20 +1217,10 @@ sub _StringLimit {
         $value = 'NULL';
     }
 
-    if ($field eq "Status") {
-        if ( ref $value eq 'ARRAY' ) {
-            $value = [ map lc, @$value ];
-        }
-        else {
-            $value = lc $value;
-        }
-    }
-
     $sb->Limit(
         FIELD         => $field,
         OPERATOR      => $op,
         VALUE         => $value,
-        CASESENSITIVE => 0,
         @rest,
     );
 }
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index bf2540efcc..c00bb70b18 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -725,20 +725,10 @@ sub _StringLimit {
         $value = 'NULL';
     }
 
-    if ($field eq "Status") {
-        if ( ref $value eq 'ARRAY' ) {
-            $value = [ map lc, @$value ];
-        }
-        else {
-            $value = lc $value;
-        }
-    }
-
     $sb->Limit(
         FIELD         => $field,
         OPERATOR      => $op,
         VALUE         => $value,
-        CASESENSITIVE => 0,
         @rest,
     );
 }
@@ -906,7 +896,6 @@ sub _TransLimit {
         FIELD         => $field,
         OPERATOR      => $op,
         VALUE         => $value,
-        CASESENSITIVE => 0,
     );
 }
 
diff --git a/lib/RT/Transactions.pm b/lib/RT/Transactions.pm
index 0c33e6b135..fde5c9a7ef 100644
--- a/lib/RT/Transactions.pm
+++ b/lib/RT/Transactions.pm
@@ -456,7 +456,6 @@ sub _StringLimit {
         FIELD         => $field,
         OPERATOR      => $op,
         VALUE         => $value,
-        CASESENSITIVE => 0,
         @rest,
     );
 }
@@ -860,7 +859,6 @@ sub _TicketLimit {
         FIELD         => $field,
         OPERATOR      => $op,
         VALUE         => $value,
-        CASESENSITIVE => 0,
     );
 }
 

commit 20d695f654ce855859a7ec9fa41e4ce754ea62fb
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Mar 23 15:49:18 2023 +0800

    Mark more fields that contain user inputs case insensitive
    
    With this, we won't need to explicitly pass CASESENSITIVE => 0 to search
    them case insensitively.

diff --git a/lib/RT/Article.pm b/lib/RT/Article.pm
index 590b4fb989..43f6ba1696 100644
--- a/lib/RT/Article.pm
+++ b/lib/RT/Article.pm
@@ -836,9 +836,9 @@ sub _CoreAccessible {
         id =>
                 {read => 1, type => 'int(11)', default => ''},
         Name => 
-                {read => 1, write => 1, type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, type => 'varchar(255)', default => '', is_case_sensitive => 0},
         Summary => 
-                {read => 1, write => 1, type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, type => 'varchar(255)', default => '', is_case_sensitive => 0},
         SortOrder => 
                 {read => 1, write => 1, type => 'int(11)', default => '0', is_numeric => 1},
         Class => 
diff --git a/lib/RT/Asset.pm b/lib/RT/Asset.pm
index 68bb48fb74..822ed46ab6 100644
--- a/lib/RT/Asset.pm
+++ b/lib/RT/Asset.pm
@@ -691,7 +691,7 @@ sub _CoreAccessible {
         id            => { read => 1, type => 'int(11)',        default => '' },
         Name          => { read => 1, type => 'varchar(255)',   default => '',  write => 1, is_case_sensitive => 0 },
         Status        => { read => 1, type => 'varchar(64)',    default => '',  write => 1, is_case_sensitive => 0 },
-        Description   => { read => 1, type => 'varchar(255)',   default => '',  write => 1 },
+        Description   => { read => 1, type => 'varchar(255)',   default => '',  write => 1, is_case_sensitive => 0 },
         Catalog       => { read => 1, type => 'int(11)',        default => '0', write => 1 },
         Creator       => { read => 1, type => 'int(11)',        default => '0', auto => 1 },
         Created       => { read => 1, type => 'datetime',       default => '',  auto => 1 },
diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 5254c2c407..5767247f6c 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -1292,9 +1292,9 @@ sub _CoreAccessible {
         Parent =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(19)', default => '0'},
         MessageId =>
-                {read => 1, write => 1, sql_type => 12, length => 160,  is_blob => 0,  is_numeric => 0,  type => 'varchar(160)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 160,  is_blob => 0,  is_numeric => 0,  type => 'varchar(160)', default => '', is_case_sensitive => 0},
         Subject =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         Filename =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         ContentType =>
@@ -1304,7 +1304,7 @@ sub _CoreAccessible {
         Content =>
                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'longblob', default => ''},
         Headers =>
-                {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'longtext', default => ''},
+                {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'longtext', default => '', is_case_sensitive => 0},
         Creator =>
                 {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Created =>
diff --git a/lib/RT/Attribute.pm b/lib/RT/Attribute.pm
index d8d2db1434..b5a55de514 100644
--- a/lib/RT/Attribute.pm
+++ b/lib/RT/Attribute.pm
@@ -776,7 +776,7 @@ sub _CoreAccessible {
         Name =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         Description =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         Content =>
                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'blob', default => ''},
         ContentType =>
diff --git a/lib/RT/Catalog.pm b/lib/RT/Catalog.pm
index 52b3102b1d..a1fa186708 100644
--- a/lib/RT/Catalog.pm
+++ b/lib/RT/Catalog.pm
@@ -489,8 +489,8 @@ sub _CoreAccessible {
     {
         id            => { read => 1, type => 'int(11)',        default => '' },
         Name          => { read => 1, type => 'varchar(255)',   default => '',          write => 1, is_case_sensitive => 0 },
-        Description   => { read => 1, type => 'varchar(255)',   default => '',          write => 1 },
-        Lifecycle     => { read => 1, type => 'varchar(32)',    default => 'assets',    write => 1 },
+        Description   => { read => 1, type => 'varchar(255)',   default => '',          write => 1, is_case_sensitive => 0 },
+        Lifecycle     => { read => 1, type => 'varchar(32)',    default => 'assets',    write => 1, is_case_sensitive => 0 },
         Disabled      => { read => 1, type => 'int(2)',         default => '0',         write => 1 },
         Creator       => { read => 1, type => 'int(11)',        default => '0', auto => 1 },
         Created       => { read => 1, type => 'datetime',       default => '',  auto => 1 },
diff --git a/lib/RT/Class.pm b/lib/RT/Class.pm
index 236d8548d9..a428261538 100644
--- a/lib/RT/Class.pm
+++ b/lib/RT/Class.pm
@@ -520,9 +520,9 @@ sub _CoreAccessible {
         id =>
                 {read => 1, type => 'int(11)', default => ''},
         Name => 
-                {read => 1, write => 1, type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, type => 'varchar(255)', default => '', is_case_sensitive => 0},
         Description => 
-                {read => 1, write => 1, type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, type => 'varchar(255)', default => '', is_case_sensitive => 0},
         SortOrder => 
                 {read => 1, write => 1, type => 'int(11)', default => '0'},
         Disabled => 
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index e81a83ee90..4c380cff47 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -2558,7 +2558,7 @@ sub _CoreAccessible {
         id =>
         {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Name => 
-        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         Type => 
         {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
         RenderType => 
@@ -2572,13 +2572,13 @@ sub _CoreAccessible {
         BasedOn => 
         {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Description => 
-        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         SortOrder => 
         {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         LookupType => 
         {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         EntryHint =>
-        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0, is_numeric => 0,  type => 'varchar(255)', default => undef },
+        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0, is_numeric => 0,  type => 'varchar(255)', default => undef, is_case_sensitive => 0 },
         UniqueValues =>
         {read => 1, write => 1, sql_type => 5, length => 6,  is_blob => 0,  is_numeric => 1,  type => 'smallint(6)', default => '0'},
         CanonicalizeClass =>
diff --git a/lib/RT/CustomRole.pm b/lib/RT/CustomRole.pm
index cf22198491..a39e7b8a52 100644
--- a/lib/RT/CustomRole.pm
+++ b/lib/RT/CustomRole.pm
@@ -824,13 +824,13 @@ sub _CoreAccessible {
         id =>
         {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Name =>
-        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         Description =>
-        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         MaxValues =>
         {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         EntryHint =>
-        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         LookupType =>
         {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         Creator =>
diff --git a/lib/RT/Group.pm b/lib/RT/Group.pm
index 28d2452d9c..33c47aaea7 100644
--- a/lib/RT/Group.pm
+++ b/lib/RT/Group.pm
@@ -1528,7 +1528,7 @@ sub _CoreAccessible {
         Name =>
                 {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         Description =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         Domain =>
                 {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => '', is_case_sensitive => 0},
         Instance =>
diff --git a/lib/RT/ObjectCustomFieldValue.pm b/lib/RT/ObjectCustomFieldValue.pm
index 1f8eba5680..074680a737 100644
--- a/lib/RT/ObjectCustomFieldValue.pm
+++ b/lib/RT/ObjectCustomFieldValue.pm
@@ -752,7 +752,7 @@ sub _CoreAccessible {
         Content =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         LargeContent =>
-                {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'longblob', default => ''},
+                {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'longblob', default => '', is_case_sensitive => 0},
         ContentType =>
                 {read => 1, write => 1, sql_type => 12, length => 80,  is_blob => 0,  is_numeric => 0,  type => 'varchar(80)', default => ''},
         ContentEncoding =>
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index 08d45e89f4..7e2c8ecd4a 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -997,15 +997,15 @@ sub _CoreAccessible {
         Name => 
         {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0 },
         Description => 
-        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         CorrespondAddress => 
-        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => '', is_case_sensitive => 0},
         CommentAddress => 
-        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => '', is_case_sensitive => 0},
         SubjectTag => 
-        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => '', is_case_sensitive => 0},
         Lifecycle => 
-        {read => 1, write => 1, sql_type => 12, length => 32,  is_blob => 0, is_numeric => 0,  type => 'varchar(32)', default => 'default'},
+        {read => 1, write => 1, sql_type => 12, length => 32,  is_blob => 0, is_numeric => 0,  type => 'varchar(32)', default => 'default', is_case_sensitive => 0},
         SortOrder => 
         {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Creator => 
diff --git a/lib/RT/Scrip.pm b/lib/RT/Scrip.pm
index dd488f6730..66fdf9dbe5 100644
--- a/lib/RT/Scrip.pm
+++ b/lib/RT/Scrip.pm
@@ -1079,7 +1079,7 @@ sub _CoreAccessible {
         id =>
                 {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Description =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         ScripCondition =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         ScripAction =>
diff --git a/lib/RT/ScripCondition.pm b/lib/RT/ScripCondition.pm
index 3aadd65871..e3664a7f09 100644
--- a/lib/RT/ScripCondition.pm
+++ b/lib/RT/ScripCondition.pm
@@ -361,9 +361,9 @@ sub _CoreAccessible {
         id =>
                 {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Name =>
-                {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         Description =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         ExecModule =>
                 {read => 1, write => 1, sql_type => 12, length => 60,  is_blob => 0,  is_numeric => 0,  type => 'varchar(60)', default => ''},
         Argument =>
diff --git a/lib/RT/Template.pm b/lib/RT/Template.pm
index 2155bf4296..fced4dfc6c 100644
--- a/lib/RT/Template.pm
+++ b/lib/RT/Template.pm
@@ -1041,9 +1041,9 @@ sub _CoreAccessible {
         Queue =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Name =>
-                {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         Description =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         Type =>
                 {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
         Content =>
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 76af2da40d..1a84820fb5 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -3672,7 +3672,7 @@ sub _CoreAccessible {
         Owner =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Subject =>
-                {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '[no subject]'},
+                {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '[no subject]', is_case_sensitive => 0},
         InitialPriority =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         FinalPriority =>
@@ -3686,7 +3686,7 @@ sub _CoreAccessible {
         Status =>
                 {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => '', is_case_sensitive => 0},
         SLA =>
-                {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => '', is_case_sensitive => 0},
         TimeLeft =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Told =>
diff --git a/lib/RT/Topic.pm b/lib/RT/Topic.pm
index 79edc1511f..f03e823f67 100644
--- a/lib/RT/Topic.pm
+++ b/lib/RT/Topic.pm
@@ -341,9 +341,9 @@ sub _CoreAccessible {
         Parent => 
                 {read => 1, write => 1, type => 'int(11)', default => ''},
         Name => 
-                {read => 1, write => 1, type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, type => 'varchar(255)', default => '', is_case_sensitive => 0},
         Description => 
-                {read => 1, write => 1, type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, type => 'varchar(255)', default => '', is_case_sensitive => 0},
         ObjectType => 
                 {read => 1, write => 1, type => 'varchar(64)', default => ''},
         ObjectId => 
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 526a90bfb0..51e1f7501d 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -2083,9 +2083,9 @@ sub _CoreAccessible {
         Field =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         OldValue =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         NewValue =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         ReferenceType =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         OldReference =>
@@ -2093,7 +2093,7 @@ sub _CoreAccessible {
         NewReference =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Data =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         Creator =>
                 {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Created =>
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index 2d4986365a..b34565dc40 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -2869,45 +2869,45 @@ sub _CoreAccessible {
         AuthToken => 
         {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
         Comments => 
-        {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
+        {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => '', is_case_sensitive => 0},
         Signature => 
-        {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
+        {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => '', is_case_sensitive => 0},
         EmailAddress => 
         {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => '', is_case_sensitive => 0},
         FreeformContactInfo => 
         {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
         Organization => 
-        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         RealName => 
-        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => '', is_case_sensitive => 0},
         NickName => 
-        {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => '', is_case_sensitive => 0},
         Lang => 
-        {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => '', is_case_sensitive => 0},
         Gecos => 
-        {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => '', is_case_sensitive => 0},
         HomePhone => 
-        {read => 1, write => 1, sql_type => 12, length => 30,  is_blob => 0,  is_numeric => 0,  type => 'varchar(30)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 30,  is_blob => 0,  is_numeric => 0,  type => 'varchar(30)', default => '', is_case_sensitive => 0},
         WorkPhone => 
-        {read => 1, write => 1, sql_type => 12, length => 30,  is_blob => 0,  is_numeric => 0,  type => 'varchar(30)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 30,  is_blob => 0,  is_numeric => 0,  type => 'varchar(30)', default => '', is_case_sensitive => 0},
         MobilePhone => 
-        {read => 1, write => 1, sql_type => 12, length => 30,  is_blob => 0,  is_numeric => 0,  type => 'varchar(30)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 30,  is_blob => 0,  is_numeric => 0,  type => 'varchar(30)', default => '', is_case_sensitive => 0},
         PagerPhone => 
-        {read => 1, write => 1, sql_type => 12, length => 30,  is_blob => 0,  is_numeric => 0,  type => 'varchar(30)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 30,  is_blob => 0,  is_numeric => 0,  type => 'varchar(30)', default => '', is_case_sensitive => 0},
         Address1 => 
-        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         Address2 => 
-        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         City => 
-        {read => 1, write => 1, sql_type => 12, length => 100,  is_blob => 0,  is_numeric => 0,  type => 'varchar(100)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 100,  is_blob => 0,  is_numeric => 0,  type => 'varchar(100)', default => '', is_case_sensitive => 0},
         State => 
-        {read => 1, write => 1, sql_type => 12, length => 100,  is_blob => 0,  is_numeric => 0,  type => 'varchar(100)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 100,  is_blob => 0,  is_numeric => 0,  type => 'varchar(100)', default => '', is_case_sensitive => 0},
         Zip => 
-        {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => '', is_case_sensitive => 0},
         Country => 
-        {read => 1, write => 1, sql_type => 12, length => 50,  is_blob => 0,  is_numeric => 0,  type => 'varchar(50)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 50,  is_blob => 0,  is_numeric => 0,  type => 'varchar(50)', default => '', is_case_sensitive => 0},
         Timezone => 
-        {read => 1, write => 1, sql_type => 12, length => 50,  is_blob => 0,  is_numeric => 0,  type => 'varchar(50)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 50,  is_blob => 0,  is_numeric => 0,  type => 'varchar(50)', default => '', is_case_sensitive => 0},
         SMIMECertificate =>
         {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
         Creator => 

commit e7b789980cb5c07b1cba8fd67835789f9a0be716
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 1 03:27:01 2022 +0800

    Support case insensitive "IN" searches for all fields
    
    Previously we implemented it only for specifiec fields like group names,
    this commit abstracts it so it could be used for all case insensitive
    fields.

diff --git a/lib/RT/Assets.pm b/lib/RT/Assets.pm
index 8698cf00c0..bc9f942073 100644
--- a/lib/RT/Assets.pm
+++ b/lib/RT/Assets.pm
@@ -696,10 +696,8 @@ sub CurrentUserCanSee {
         $groups->Limit( FIELD => 'Domain', VALUE => 'RT::Catalog-Role', CASESENSITIVE => 0 );
         $groups->Limit(
             FIELD         => 'Name',
-            FUNCTION      => 'LOWER(?)',
             OPERATOR      => 'IN',
-            VALUE         => [ map {lc $_} @tmp ],
-            CASESENSITIVE => 1,
+            VALUE         => \@tmp,
         );
         my $principal_alias = $groups->Join(
             ALIAS1 => 'main',
diff --git a/lib/RT/CustomFields.pm b/lib/RT/CustomFields.pm
index 7615799052..56d11cac44 100644
--- a/lib/RT/CustomFields.pm
+++ b/lib/RT/CustomFields.pm
@@ -151,10 +151,8 @@ sub LimitToGrouping {
         }
         $self->Limit(
             FIELD         => 'Name',
-            FUNCTION      => 'LOWER(?)',
             OPERATOR      => 'IN',
-            VALUE         => [map {lc $_} @{$list}],
-            CASESENSITIVE => 1,
+            VALUE         => $list,
         );
     } else {
         my @list = map {@$_} grep defined && ref($_) eq 'ARRAY',
@@ -164,10 +162,8 @@ sub LimitToGrouping {
 
         $self->Limit(
             FIELD         => 'Name',
-            FUNCTION      => 'LOWER(?)',
             OPERATOR      => 'NOT IN',
-            VALUE         => [ map {lc $_} @list ],
-            CASESENSITIVE => 1,
+            VALUE         => \@list,
         );
     }
     return;
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 17dfc131e2..1b02ba5da6 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -4259,10 +4259,8 @@ sub GetPrincipalsMap {
                     $roles->LimitToRolesForObject(RT->System);
                     $roles->Limit(
                         FIELD         => "Name",
-                        FUNCTION      => 'LOWER(?)',
                         OPERATOR      => "IN",
-                        VALUE         => [ map {lc $_} $class->Roles ],
-                        CASESENSITIVE => 1,
+                        VALUE         => [ $class->Roles ],
                     );
                 } else {
                     # No roles to show; so show nothing
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 86190ae46d..31585baf96 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -993,6 +993,22 @@ sub Limit {
         $ARGS{'CASESENSITIVE'} //= 1;
     }
 
+    # Convert IN searches like "Status IN ( 'new', 'open' )" to "LOWER(Status) IN ( 'new', 'open' )"
+    if (
+           $self->_Handle->CaseSensitive
+        && !$ARGS{CASESENSITIVE}
+        && !$ARGS{FUNCTION}
+        && $ARGS{OPERATOR} =~ /\bIN\b/i
+        && ( $ARGS{QUOTEVALUE} || !exists $ARGS{QUOTEVALUE} )    # QUOTEVALUE defaults to true in DBIx::SearchBuilder
+        && ref $ARGS{VALUE} eq 'ARRAY'
+        && grep( /\D/, @{ $ARGS{VALUE} } )
+        )
+    {
+        $ARGS{FUNCTION}      = 'LOWER(?)';
+        $ARGS{VALUE}         = [ map lc, @{ $ARGS{VALUE} } ];
+        $ARGS{CASESENSITIVE} = 1;
+    }
+
     # Oracle doesn't support to directly compare CLOB with VARCHAR/INTEGER.
     # DefaultDashboard search in RT::Dashboard::CurrentUserCanDelete needs this
     if (   $ARGS{OPERATOR} !~ /IS/i
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index e58ad24a28..bf2540efcc 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -2794,10 +2794,8 @@ sub CurrentUserCanSee {
         $groups->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
         $groups->Limit(
             FIELD         => 'Name',
-            FUNCTION      => 'LOWER(?)',
             OPERATOR      => 'IN',
-            VALUE         => [ map {lc $_} @tmp ],
-            CASESENSITIVE => 1,
+            VALUE         => \@tmp,
         );
         my $principal_alias = $groups->Join(
             ALIAS1 => 'main',

commit 21b4ddbb44b2fe3a169a43311c793402f7031fa7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Sep 30 23:08:49 2022 +0800

    Default searches to be case insensitive for fields with lower cased indexes
    
    Previously we had to manually pass CASESENSITIVE arg. We don't need to
    do so any more with this commit.

diff --git a/lib/RT/Asset.pm b/lib/RT/Asset.pm
index c29e58f67d..68bb48fb74 100644
--- a/lib/RT/Asset.pm
+++ b/lib/RT/Asset.pm
@@ -689,8 +689,8 @@ sub Table { "Assets" }
 sub _CoreAccessible {
     {
         id            => { read => 1, type => 'int(11)',        default => '' },
-        Name          => { read => 1, type => 'varchar(255)',   default => '',  write => 1 },
-        Status        => { read => 1, type => 'varchar(64)',    default => '',  write => 1 },
+        Name          => { read => 1, type => 'varchar(255)',   default => '',  write => 1, is_case_sensitive => 0 },
+        Status        => { read => 1, type => 'varchar(64)',    default => '',  write => 1, is_case_sensitive => 0 },
         Description   => { read => 1, type => 'varchar(255)',   default => '',  write => 1 },
         Catalog       => { read => 1, type => 'int(11)',        default => '0', write => 1 },
         Creator       => { read => 1, type => 'int(11)',        default => '0', auto => 1 },
diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 03af410a5b..5254c2c407 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -1296,7 +1296,7 @@ sub _CoreAccessible {
         Subject =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         Filename =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         ContentType =>
                 {read => 1, write => 1, sql_type => 12, length => 80,  is_blob => 0,  is_numeric => 0,  type => 'varchar(80)', default => ''},
         ContentEncoding =>
diff --git a/lib/RT/Catalog.pm b/lib/RT/Catalog.pm
index 415042330d..52b3102b1d 100644
--- a/lib/RT/Catalog.pm
+++ b/lib/RT/Catalog.pm
@@ -488,7 +488,7 @@ sub Table { "Catalogs" }
 sub _CoreAccessible {
     {
         id            => { read => 1, type => 'int(11)',        default => '' },
-        Name          => { read => 1, type => 'varchar(255)',   default => '',          write => 1 },
+        Name          => { read => 1, type => 'varchar(255)',   default => '',          write => 1, is_case_sensitive => 0 },
         Description   => { read => 1, type => 'varchar(255)',   default => '',          write => 1 },
         Lifecycle     => { read => 1, type => 'varchar(32)',    default => 'assets',    write => 1 },
         Disabled      => { read => 1, type => 'int(2)',         default => '0',         write => 1 },
diff --git a/lib/RT/Configuration.pm b/lib/RT/Configuration.pm
index 2952e251b4..9fd0e91c85 100644
--- a/lib/RT/Configuration.pm
+++ b/lib/RT/Configuration.pm
@@ -499,7 +499,7 @@ sub Table { "Configurations" }
 sub _CoreAccessible {
     {
         id            => { read => 1, type => 'int(11)',        default => '' },
-        Name          => { read => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+        Name          => { read => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         Content       => { read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'blob', default => ''},
         ContentType   => { read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
         Disabled      => { read => 1, write => 1, sql_type => 5, length => 6,  is_blob => 0,  is_numeric => 1,  type => 'smallint(6)', default => '0'},
diff --git a/lib/RT/Group.pm b/lib/RT/Group.pm
index 9fc202d001..28d2452d9c 100644
--- a/lib/RT/Group.pm
+++ b/lib/RT/Group.pm
@@ -1526,11 +1526,11 @@ sub _CoreAccessible {
         id =>
                 {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Name =>
-                {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         Description =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         Domain =>
-                {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => '', is_case_sensitive => 0},
         Instance =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Creator =>
diff --git a/lib/RT/ObjectCustomFieldValue.pm b/lib/RT/ObjectCustomFieldValue.pm
index e28c33765c..1f8eba5680 100644
--- a/lib/RT/ObjectCustomFieldValue.pm
+++ b/lib/RT/ObjectCustomFieldValue.pm
@@ -750,7 +750,7 @@ sub _CoreAccessible {
         SortOrder =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Content =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         LargeContent =>
                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'longblob', default => ''},
         ContentType =>
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index 1f3af9c9d0..08d45e89f4 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -995,7 +995,7 @@ sub _CoreAccessible {
         id =>
         {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Name => 
-        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0 },
         Description => 
         {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         CorrespondAddress => 
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 4a740d73b5..86190ae46d 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -932,13 +932,6 @@ injection attacks when we pass through user specified values.
 
 =cut
 
-my %check_case_sensitivity = (
-    groups => { 'name' => 1, domain => 1 },
-    queues => { 'name' => 1 },
-    users => { 'name' => 1, emailaddress => 1 },
-    customfields => { 'name' => 1 },
-);
-
 my %deprecated = (
 );
 
@@ -988,15 +981,16 @@ sub Limit {
     }
 
     unless ( exists $ARGS{CASESENSITIVE} or (exists $ARGS{QUOTEVALUE} and not $ARGS{QUOTEVALUE}) ) {
-        if ( $ARGS{FIELD} and $ARGS{'OPERATOR'} !~ /IS/i
-            && $table && $check_case_sensitivity{ lc $table }{ lc $ARGS{'FIELD'} }
-        ) {
-            RT->Logger->warning(
-                "Case sensitive search by $table.$ARGS{'FIELD'}"
-                ." at ". (caller)[1] . " line ". (caller)[2]
-            );
+
+        # Set CASESENSITIVE from field declaration
+        my $class = "RT::$table";
+        if ( $class->can('RecordClass') && $class->RecordClass && $class->RecordClass->can('_CoreAccessible') ) {
+            if ( my $meta = $class->RecordClass->_CoreAccessible->{ $ARGS{FIELD} } ) {
+                $ARGS{'CASESENSITIVE'} = $meta->{is_case_sensitive};
+            }
         }
-        $ARGS{'CASESENSITIVE'} = 1;
+
+        $ARGS{'CASESENSITIVE'} //= 1;
     }
 
     # Oracle doesn't support to directly compare CLOB with VARCHAR/INTEGER.
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 5592929bb3..76af2da40d 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -3684,7 +3684,7 @@ sub _CoreAccessible {
         TimeWorked =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Status =>
-                {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => '', is_case_sensitive => 0},
         SLA =>
                 {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => ''},
         TimeLeft =>
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index 7134085a66..2d4986365a 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -2863,7 +2863,7 @@ sub _CoreAccessible {
         id =>
         {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Name => 
-        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         Password => 
         {read => 1, write => 1, sql_type => 12, length => 256,  is_blob => 0,  is_numeric => 0,  type => 'varchar(256)', default => ''},
         AuthToken => 
@@ -2873,7 +2873,7 @@ sub _CoreAccessible {
         Signature => 
         {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
         EmailAddress => 
-        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => '', is_case_sensitive => 0},
         FreeformContactInfo => 
         {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
         Organization => 

commit 0e87746b04be010bc488122aaeefbf9fc648b5d0
Author: Brian Conry <bconry at bestpractical.com>
Date:   Wed Mar 30 14:03:10 2022 -0500

    Make lower cased indexes on char columns that contain user inputs for Oracle
    
    Now that we're searching them with LOWER(), we need the lower cased
    indexes accordingly.

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index 7b7ac07475..1c2e205305 100644
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -17,7 +17,7 @@ CREATE TABLE Attachments (
 );
 CREATE INDEX Attachments2 ON Attachments (TransactionId);
 CREATE INDEX Attachments3 ON Attachments (Parent, TransactionId);
-CREATE INDEX Attachments4 ON Attachments (Filename);
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
 
 
 CREATE SEQUENCE QUEUES_seq;
@@ -271,7 +271,7 @@ CREATE TABLE Tickets (
         Creator                 NUMBER(11,0) DEFAULT 0 NOT NULL,
         Created                 DATE
 );
-CREATE INDEX Tickets1 ON Tickets (Queue, Status);
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
 CREATE INDEX Tickets2 ON Tickets (Owner);
 CREATE INDEX Tickets6 ON Tickets (EffectiveId, Type);
 
@@ -342,7 +342,7 @@ CREATE TABLE ObjectCustomFieldValues (
         Disabled        NUMBER(11,0) DEFAULT 0 NOT NULL
 );
 
-CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (Content); 
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (LOWER(Content)); 
 CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
 
 CREATE SEQUENCE CUSTOMFIELDS_seq;
@@ -493,7 +493,7 @@ CREATE TABLE Assets (
 );
 
 CREATE INDEX AssetsName ON Assets (LOWER(Name));
-CREATE INDEX AssetsStatus ON Assets (Status);
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
 CREATE INDEX AssetsCatalog ON Assets (Catalog);
 
 CREATE SEQUENCE Catalogs_seq;
diff --git a/etc/upgrade/5.0.4/schema.Oracle b/etc/upgrade/5.0.4/schema.Oracle
index 300bf8d8b6..67c43908b3 100644
--- a/etc/upgrade/5.0.4/schema.Oracle
+++ b/etc/upgrade/5.0.4/schema.Oracle
@@ -1,2 +1,10 @@
 ALTER TABLE CustomRoles ADD LookupType VARCHAR2(255);
 UPDATE CustomRoles SET LookupType='RT::Queue-RT::Ticket';
+DROP INDEX Tickets1;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
+DROP INDEX AssetsStatus;
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
+DROP INDEX Attachments4;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
+DROP INDEX ObjectCustomFieldValues1;
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (LOWER(Content));

commit 8b312d02867650e65a892cd3ece8c87061e9fbfc
Author: Brian Conry <bconry at bestpractical.com>
Date:   Wed Mar 30 13:10:45 2022 -0500

    Make lower cased indexes on char columns that contain user inputs for Pg
    
    Now that we're searching them with LOWER(), we need the lower cased
    indexes accordingly.

diff --git a/etc/schema.Pg b/etc/schema.Pg
index 0c81859312..ba470daeb6 100644
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -33,7 +33,7 @@ CREATE TABLE Attachments (
 CREATE INDEX Attachments1 ON Attachments (Parent) ;
 CREATE INDEX Attachments2 ON Attachments (TransactionId) ;
 CREATE INDEX Attachments3 ON Attachments (Parent, TransactionId) ;
-CREATE INDEX Attachments4 ON Attachments (Filename) ;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
 
 
 
@@ -429,7 +429,7 @@ CREATE TABLE Tickets (
 
 );
 
-CREATE INDEX Tickets1 ON Tickets (Queue, Status) ;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
 CREATE INDEX Tickets2 ON Tickets (Owner) ;
 CREATE INDEX Tickets3 ON Tickets (EffectiveId) ;
 
@@ -514,7 +514,7 @@ CREATE TABLE ObjectCustomFieldValues (
 
 );
 
-CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId,Content); 
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId,LOWER(Content)); 
 CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
 
 
@@ -725,7 +725,7 @@ CREATE TABLE Assets (
 );
 
 CREATE INDEX AssetsName ON Assets (LOWER(Name));
-CREATE INDEX AssetsStatus ON Assets (Status);
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
 CREATE INDEX AssetsCatalog ON Assets (Catalog);
 
 CREATE SEQUENCE catalogs_id_seq;
diff --git a/etc/upgrade/5.0.4/schema.Pg b/etc/upgrade/5.0.4/schema.Pg
index 671d871f45..196e86bb44 100644
--- a/etc/upgrade/5.0.4/schema.Pg
+++ b/etc/upgrade/5.0.4/schema.Pg
@@ -1,2 +1,10 @@
 ALTER TABLE CustomRoles ADD COLUMN LookupType VARCHAR(255);
 UPDATE CustomRoles SET LookupType='RT::Queue-RT::Ticket';
+DROP INDEX Tickets1;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
+DROP INDEX AssetsStatus;
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
+DROP INDEX Attachments4;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
+DROP INDEX ObjectCustomFieldValues1;
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField, ObjectType, ObjectId, LOWER(Content));

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list