Defect #20438
closedSubject filter doesn't work with non ASCII uppercase symbols
Description
If you search by containing cyrillic uppercase symbols, you get empty result. The query for search looks like
when "~"
sql = "LOWER(#{db_table}.#{db_field}) LIKE '%#{self.class.connection.quote_string(value.first.to_s.downcase)}%'"
but ruby function downcase wokrs only with latin symbols.
We add special private method:
def like_operator(content)
if Redmine::Database.postgresql?
"ILIKE '%#{content}%' "
else
"LIKE LOWER(#{content})"
end
end
and override method sql_for_field
when "~"
sql = "LOWER(#{db_table}.#{db_field}) #{like_operator(self.class.connection.quote_string(value.first.to_s.downcase))}"
when "!~"
sql = "LOWER(#{db_table}.#{db_field}) NOT #{like_operator(self.class.connection.quote_string(value.first.to_s.downcase))}"