summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-08-02 08:32:18 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-08-02 08:32:18 +0000
commitd4723bb05ff43a4c6e282b12249c71697f7929ce (patch)
treecb74d5b98211bf095b34eb08fda3c8382183b8e1 /lib
parentdf1093a4afd5799bef71143582646840174a615c (diff)
downloadredmine-d4723bb05ff43a4c6e282b12249c71697f7929ce.tar.gz
redmine-d4723bb05ff43a4c6e282b12249c71697f7929ce.zip
Query doesn't work with non ASCII uppercase symbols (#20438).
git-svn-id: http://svn.redmine.org/redmine/trunk@14476 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb10
-rw-r--r--lib/redmine/database.rb15
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb b/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb
index 96d1c2588..06d5db7de 100644
--- a/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb
+++ b/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb
@@ -159,15 +159,7 @@ module Redmine
private :search_tokens_condition
def search_token_match_statement(column, value='?')
- if Redmine::Database.postgresql?
- if Redmine::Database.postgresql_unaccent?
- "unaccent(#{column}) ILIKE unaccent(#{value})"
- else
- "#{column} ILIKE #{value}"
- end
- else
- "#{column} LIKE #{value}"
- end
+ Redmine::Database.like(column, value)
end
private :search_token_match_statement
diff --git a/lib/redmine/database.rb b/lib/redmine/database.rb
index 290c78ea4..d8b4b7ccb 100644
--- a/lib/redmine/database.rb
+++ b/lib/redmine/database.rb
@@ -44,6 +44,21 @@ module Redmine
end
end
+ # Returns a SQL statement for case/accent (if possible) insensitive match
+ def like(left, right, options={})
+ neg = (options[:match] == false ? 'NOT ' : '')
+
+ if postgresql?
+ if postgresql_unaccent?
+ "unaccent(#{left}) #{neg}ILIKE unaccent(#{right})"
+ else
+ "#{left} #{neg}ILIKE #{right}"
+ end
+ else
+ "#{left} #{neg}LIKE #{right}"
+ end
+ end
+
# Resets database information
def reset
@postgresql_unaccent = nil