Fixed: case sensitivity in issue subject filtering (#3536).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2796 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
aa07e8505e
commit
a7bb63a182
|
@ -424,9 +424,9 @@ class Query < ActiveRecord::Base
|
|||
Time.now.at_beginning_of_week
|
||||
sql = "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)]
|
||||
when "~"
|
||||
sql = "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(value.first)}%'"
|
||||
sql = "LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'"
|
||||
when "!~"
|
||||
sql = "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(value.first)}%'"
|
||||
sql = "LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'"
|
||||
end
|
||||
|
||||
return sql
|
||||
|
|
|
@ -150,15 +150,17 @@ class QueryTest < Test::Unit::TestCase
|
|||
|
||||
def test_operator_contains
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('subject', '~', ['string'])
|
||||
assert query.statement.include?("#{Issue.table_name}.subject LIKE '%string%'")
|
||||
find_issues_with_query(query)
|
||||
query.add_filter('subject', '~', ['uNable'])
|
||||
assert query.statement.include?("LOWER(#{Issue.table_name}.subject) LIKE '%unable%'")
|
||||
result = find_issues_with_query(query)
|
||||
assert result.empty?
|
||||
result.each {|issue| assert issue.subject.downcase.include?('unable') }
|
||||
end
|
||||
|
||||
def test_operator_does_not_contains
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('subject', '!~', ['string'])
|
||||
assert query.statement.include?("#{Issue.table_name}.subject NOT LIKE '%string%'")
|
||||
query.add_filter('subject', '!~', ['uNable'])
|
||||
assert query.statement.include?("LOWER(#{Issue.table_name}.subject) NOT LIKE '%unable%'")
|
||||
find_issues_with_query(query)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue