mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-28 19:29:38 +00:00
Restore accent insensitive search with mysql (#18537).
git-svn-id: http://svn.redmine.org/redmine/trunk@13767 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
15bb695bbb
commit
30175bf85e
@ -121,8 +121,6 @@ module Redmine
|
||||
case connection.adapter_name
|
||||
when /postgresql/i
|
||||
"#{column} ILIKE #{value}"
|
||||
when /mysql/i
|
||||
"LOWER(#{column}) COLLATE utf8_bin LIKE LOWER(#{value})"
|
||||
else
|
||||
"#{column} LIKE #{value}"
|
||||
end
|
||||
|
||||
@ -167,6 +167,10 @@ class ActiveSupport::TestCase
|
||||
ActiveRecord::Base.connection.adapter_name =~ /sqlite/i
|
||||
end
|
||||
|
||||
def mysql?
|
||||
ActiveRecord::Base.connection.adapter_name =~ /mysql/i
|
||||
end
|
||||
|
||||
def assert_save(object)
|
||||
saved = object.save
|
||||
message = "#{object.class} could not be saved"
|
||||
|
||||
@ -149,17 +149,26 @@ class SearchTest < ActiveSupport::TestCase
|
||||
assert_include issue, r
|
||||
end
|
||||
|
||||
def test_search_should_not_use_ruby_downcase
|
||||
skip "SQLite does not support case insensitive match for non-ASCII characters" if sqlite?
|
||||
issue1 = Issue.generate!(:subject => "Special chars: ÖÖ")
|
||||
issue2 = Issue.generate!(:subject => "Special chars: Öö")
|
||||
Issue.generate!(:subject => "Special chars: oo")
|
||||
Issue.generate!(:subject => "Special chars: OO")
|
||||
def test_search_should_be_case_insensitive_with_accented_characters
|
||||
unless sqlite?
|
||||
issue1 = Issue.generate!(:subject => "Special chars: ÖÖ")
|
||||
issue2 = Issue.generate!(:subject => "Special chars: Öö")
|
||||
|
||||
r = Issue.search_results('ÖÖ')
|
||||
assert_include issue1, r
|
||||
assert_include issue2, r
|
||||
end
|
||||
end
|
||||
|
||||
r = Issue.search_results('ÖÖ')
|
||||
assert_include issue1, r
|
||||
assert_include issue2, r
|
||||
assert_equal 2, r.size
|
||||
def test_search_should_be_case_and_accent_insensitive_with_mysql
|
||||
if mysql?
|
||||
issue1 = Issue.generate!(:subject => "OO")
|
||||
issue2 = Issue.generate!(:subject => "oo")
|
||||
|
||||
r = Issue.search_results('ÖÖ')
|
||||
assert_include issue1, r
|
||||
assert_include issue2, r
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user