Merge pull request #3077 from evazion/fix-dmail-title-search
Fix case sensitivity bug in dmail title search.
This commit is contained in:
@@ -19,7 +19,7 @@ class Ban < ActiveRecord::Base
|
|||||||
|
|
||||||
def self.reason_matches(query)
|
def self.reason_matches(query)
|
||||||
if query =~ /\*/
|
if query =~ /\*/
|
||||||
where("lower(bans.reason) LIKE ?", query.to_escaped_for_sql_like)
|
where("lower(bans.reason) LIKE ?", query.mb_chars.downcase.to_escaped_for_sql_like)
|
||||||
else
|
else
|
||||||
where("bans.reason @@ plainto_tsquery(?)", query)
|
where("bans.reason @@ plainto_tsquery(?)", query)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class Dmail < ActiveRecord::Base
|
|||||||
|
|
||||||
def title_matches(query)
|
def title_matches(query)
|
||||||
query = "*#{query}*" unless query =~ /\*/
|
query = "*#{query}*" unless query =~ /\*/
|
||||||
where("lower(dmails.title) LIKE ?", query.to_escaped_for_sql_like)
|
where("lower(dmails.title) LIKE ?", query.mb_chars.downcase.to_escaped_for_sql_like)
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_message(query)
|
def search_message(query)
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ class DmailTest < ActiveSupport::TestCase
|
|||||||
matches = Dmail.search(title_matches: "x")
|
matches = Dmail.search(title_matches: "x")
|
||||||
assert_equal([dmail.id], matches.map(&:id))
|
assert_equal([dmail.id], matches.map(&:id))
|
||||||
|
|
||||||
|
matches = Dmail.search(title_matches: "X")
|
||||||
|
assert_equal([dmail.id], matches.map(&:id))
|
||||||
|
|
||||||
matches = Dmail.search(message_matches: "xxx")
|
matches = Dmail.search(message_matches: "xxx")
|
||||||
assert_equal([dmail.id], matches.map(&:id))
|
assert_equal([dmail.id], matches.map(&:id))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user