RSS

trunk : 6111

mkanat%bugzilla.org
2008-06-29 21:23:10
Revision ID: cvs-1:mkanatbugzilla.org-20080630022310-w5yb2olw2j2bagvp
Bug 327344: Create sql_iposition and use it in Search.pm to fix the fact that searching for Turkish characters didn't do case-insensitivity properly. Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat

collapse all collapse all

added added

removed removed

313
    return "LOWER($string)";
313
    return "LOWER($string)";
314
}
314
}
315
 
315
 
 
 
316
sub sql_iposition {
 
 
317
    my ($self, $fragment, $text) = @_;
 
 
318
    $fragment = $self->sql_istring($fragment);
 
 
319
    $text = $self->sql_istring($text);
 
 
320
    return $self->sql_position($fragment, $text);
 
 
321
}
 
 
322
 
316
sub sql_position {
323
sub sql_position {
317
    my ($self, $fragment, $text) = @_;
324
    my ($self, $fragment, $text) = @_;
318
 
325
 
1699
 
1706
 
1700
=item B<Description>
1707
=item B<Description>
1701
 
1708
 
1702
Outputs proper SQL syntax determinig position of a substring
1709
Outputs proper SQL syntax determining position of a substring
1703
(fragment) withing a string (text). Note: if the substring or
1710
(fragment) withing a string (text). Note: if the substring or
1704
text are string constants, they must be properly quoted (e.g. "'pattern'").
1711
text are string constants, they must be properly quoted (e.g. "'pattern'").
1705
 
1712
 
 
 
1713
It searches for the string in a case-sensitive manner. If you want to do
 
 
1714
a case-insensitive search, use L</sql_iposition>.
 
 
1715
 
1706
=item B<Params>
1716
=item B<Params>
1707
 
1717
 
1708
=over
1718
=over
1719
 
1729
 
1720
=back
1730
=back
1721
 
1731
 
 
 
1732
=item C<sql_iposition>
 
 
1733
 
 
 
1734
Just like L</sql_position>, but case-insensitive.
 
 
1735
 
1722
=item C<sql_group_by>
1736
=item C<sql_group_by>
1723
 
1737
 
1724
=over
1738
=over
183
    return "INTERVAL $interval $units";
183
    return "INTERVAL $interval $units";
184
}
184
}
185
 
185
 
 
 
186
sub sql_iposition {
 
 
187
    my ($self, $fragment, $text) = @_;
 
 
188
    return "INSTR($text, $fragment)";
 
 
189
}
 
 
190
 
186
sub sql_position {
191
sub sql_position {
187
    my ($self, $fragment, $text) = @_;
192
    my ($self, $fragment, $text) = @_;
188
 
193
 
189
    # mysql 4.0.1 and lower do not support CAST
 
 
190
    # (checksetup has a check for unsupported versions)
 
 
191
 
 
 
192
    my $server_version = $self->bz_server_version;
 
 
193
    return "INSTR(CAST($text AS BINARY), CAST($fragment AS BINARY))";
194
    return "INSTR(CAST($text AS BINARY), CAST($fragment AS BINARY))";
194
}
195
}
195
 
196
 
912
        if ($word ne "") {
912
        if ($word ne "") {
913
            $sql_word = $dbh->quote($word);
913
            $sql_word = $dbh->quote($word);
914
            trick_taint($sql_word);
914
            trick_taint($sql_word);
915
            push(@list, $dbh->sql_position(lc($sql_word),
915
            push(@list, $dbh->sql_iposition($sql_word, $field) . " > 0");
916
                                           "LOWER($field)") . " > 0");
 
 
917
        }
916
        }
918
    }
917
    }
919
 
918
 
1919
    my ($ff, $q, $term) = @func_args{qw(ff q term)};
1918
    my ($ff, $q, $term) = @func_args{qw(ff q term)};
1920
    my $dbh = Bugzilla->dbh;
1919
    my $dbh = Bugzilla->dbh;
1921
    
1920
    
1922
    $$term = $dbh->sql_position(lc($$q), "LOWER($$ff)") . " > 0";
1921
    $$term = $dbh->sql_iposition($$q, $$ff) . " > 0";
1923
}
1922
}
1924
 
1923
 
1925
sub _notsubstring {
1924
sub _notsubstring {
1928
    my ($ff, $q, $term) = @func_args{qw(ff q term)};
1927
    my ($ff, $q, $term) = @func_args{qw(ff q term)};
1929
    my $dbh = Bugzilla->dbh;
1928
    my $dbh = Bugzilla->dbh;
1930
    
1929
    
1931
    $$term = $dbh->sql_position(lc($$q), "LOWER($$ff)") . " = 0";
1930
    $$term = $dbh->sql_iposition($$q, $$ff) . " = 0";
1932
}
1931
}
1933
 
1932
 
1934
sub _regexp {
1933
sub _regexp {

Loggerhead runs on Bazaar branches