]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 327344: Create sql_iposition and use it in Search.pm to fix the fact that se
authormkanat%bugzilla.org <>
Mon, 30 Jun 2008 02:24:08 +0000 (02:24 +0000)
committermkanat%bugzilla.org <>
Mon, 30 Jun 2008 02:24:08 +0000 (02:24 +0000)
arching for Turkish characters didn't do case-insensitivity properly.
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat

Bugzilla/DB.pm
Bugzilla/DB/Mysql.pm
Bugzilla/Search.pm

index 1617b7fc272d631e45726960b205cfe06d06ce99..12a19d2905efbbcfc3c8856f1c7584404daedd97 100644 (file)
@@ -313,6 +313,13 @@ sub sql_istring {
     return "LOWER($string)";
 }
 
+sub sql_iposition {
+    my ($self, $fragment, $text) = @_;
+    $fragment = $self->sql_istring($fragment);
+    $text = $self->sql_istring($text);
+    return $self->sql_position($fragment, $text);
+}
+
 sub sql_position {
     my ($self, $fragment, $text) = @_;
 
@@ -1684,10 +1691,13 @@ Formatted SQL for interval function (scalar)
 
 =item B<Description>
 
-Outputs proper SQL syntax determinig position of a substring
+Outputs proper SQL syntax determining position of a substring
 (fragment) withing a string (text). Note: if the substring or
 text are string constants, they must be properly quoted (e.g. "'pattern'").
 
+It searches for the string in a case-sensitive manner. If you want to do
+a case-insensitive search, use L</sql_iposition>.
+
 =item B<Params>
 
 =over
@@ -1704,6 +1714,10 @@ Formatted SQL for substring search (scalar)
 
 =back
 
+=item C<sql_iposition>
+
+Just like L</sql_position>, but case-insensitive.
+
 =item C<sql_group_by>
 
 =over
index 8bca06f4c874480273f738683105921630edfd44..3e9d6f997f1b3b7b7f2583b382646de2794f634e 100644 (file)
@@ -179,13 +179,14 @@ sub sql_interval {
     return "INTERVAL $interval $units";
 }
 
-sub sql_position {
+sub sql_iposition {
     my ($self, $fragment, $text) = @_;
+    return "INSTR($text, $fragment)";
+}
 
-    # mysql 4.0.1 and lower do not support CAST
-    # (checksetup has a check for unsupported versions)
+sub sql_position {
+    my ($self, $fragment, $text) = @_;
 
-    my $server_version = $self->bz_server_version;
     return "INSTR(CAST($text AS BINARY), CAST($fragment AS BINARY))";
 }
 
index d74f09474f9b763292d5643762cc7f17dca8abf4..272b41152972623a2650a2c311a0483d67a8c75b 100644 (file)
@@ -912,8 +912,7 @@ sub GetByWordListSubstr {
         if ($word ne "") {
             $sql_word = $dbh->quote($word);
             trick_taint($sql_word);
-            push(@list, $dbh->sql_position(lc($sql_word),
-                                           "LOWER($field)") . " > 0");
+            push(@list, $dbh->sql_iposition($sql_word, $field) . " > 0");
         }
     }
 
@@ -1919,7 +1918,7 @@ sub _substring {
     my ($ff, $q, $term) = @func_args{qw(ff q term)};
     my $dbh = Bugzilla->dbh;
     
-    $$term = $dbh->sql_position(lc($$q), "LOWER($$ff)") . " > 0";
+    $$term = $dbh->sql_iposition($$q, $$ff) . " > 0";
 }
 
 sub _notsubstring {
@@ -1928,7 +1927,7 @@ sub _notsubstring {
     my ($ff, $q, $term) = @func_args{qw(ff q term)};
     my $dbh = Bugzilla->dbh;
     
-    $$term = $dbh->sql_position(lc($$q), "LOWER($$ff)") . " = 0";
+    $$term = $dbh->sql_iposition($$q, $$ff) . " = 0";
 }
 
 sub _regexp {