@@ -121,8 +121,6 module Redmine | |||||
121 | case connection.adapter_name |
|
121 | case connection.adapter_name | |
122 | when /postgresql/i |
|
122 | when /postgresql/i | |
123 | "#{column} ILIKE #{value}" |
|
123 | "#{column} ILIKE #{value}" | |
124 | when /mysql/i |
|
|||
125 | "LOWER(#{column}) COLLATE utf8_bin LIKE LOWER(#{value})" |
|
|||
126 | else |
|
124 | else | |
127 | "#{column} LIKE #{value}" |
|
125 | "#{column} LIKE #{value}" | |
128 | end |
|
126 | end |
@@ -167,6 +167,10 class ActiveSupport::TestCase | |||||
167 | ActiveRecord::Base.connection.adapter_name =~ /sqlite/i |
|
167 | ActiveRecord::Base.connection.adapter_name =~ /sqlite/i | |
168 | end |
|
168 | end | |
169 |
|
169 | |||
|
170 | def mysql? | |||
|
171 | ActiveRecord::Base.connection.adapter_name =~ /mysql/i | |||
|
172 | end | |||
|
173 | ||||
170 | def assert_save(object) |
|
174 | def assert_save(object) | |
171 | saved = object.save |
|
175 | saved = object.save | |
172 | message = "#{object.class} could not be saved" |
|
176 | message = "#{object.class} could not be saved" |
@@ -149,17 +149,26 class SearchTest < ActiveSupport::TestCase | |||||
149 | assert_include issue, r |
|
149 | assert_include issue, r | |
150 | end |
|
150 | end | |
151 |
|
151 | |||
152 | def test_search_should_not_use_ruby_downcase |
|
152 | def test_search_should_be_case_insensitive_with_accented_characters | |
153 | skip "SQLite does not support case insensitive match for non-ASCII characters" if sqlite? |
|
153 | unless sqlite? | |
154 | issue1 = Issue.generate!(:subject => "Special chars: ÖÖ") |
|
154 | issue1 = Issue.generate!(:subject => "Special chars: ÖÖ") | |
155 | issue2 = Issue.generate!(:subject => "Special chars: Öö") |
|
155 | issue2 = Issue.generate!(:subject => "Special chars: Öö") | |
156 | Issue.generate!(:subject => "Special chars: oo") |
|
156 | ||
157 | Issue.generate!(:subject => "Special chars: OO") |
|
157 | r = Issue.search_results('ÖÖ') | |
158 |
|
158 | assert_include issue1, r | ||
159 | r = Issue.search_results('ÖÖ') |
|
159 | assert_include issue2, r | |
160 | assert_include issue1, r |
|
160 | end | |
161 | assert_include issue2, r |
|
161 | end | |
162 | assert_equal 2, r.size |
|
162 | ||
|
163 | def test_search_should_be_case_and_accent_insensitive_with_mysql | |||
|
164 | if mysql? | |||
|
165 | issue1 = Issue.generate!(:subject => "OO") | |||
|
166 | issue2 = Issue.generate!(:subject => "oo") | |||
|
167 | ||||
|
168 | r = Issue.search_results('ÖÖ') | |||
|
169 | assert_include issue1, r | |||
|
170 | assert_include issue2, r | |||
|
171 | end | |||
163 | end |
|
172 | end | |
164 |
|
173 | |||
165 | private |
|
174 | private |
General Comments 0
You need to be logged in to leave comments.
Login now