@@ -424,9 +424,9 class Query < ActiveRecord::Base | |||||
424 | Time.now.at_beginning_of_week |
|
424 | Time.now.at_beginning_of_week | |
425 | sql = "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)] |
|
425 | sql = "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)] | |
426 | when "~" |
|
426 | when "~" | |
427 | sql = "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(value.first)}%'" |
|
427 | sql = "LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'" | |
428 | when "!~" |
|
428 | when "!~" | |
429 | sql = "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(value.first)}%'" |
|
429 | sql = "LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'" | |
430 | end |
|
430 | end | |
431 |
|
431 | |||
432 | return sql |
|
432 | return sql |
@@ -150,15 +150,17 class QueryTest < Test::Unit::TestCase | |||||
150 |
|
150 | |||
151 | def test_operator_contains |
|
151 | def test_operator_contains | |
152 | query = Query.new(:project => Project.find(1), :name => '_') |
|
152 | query = Query.new(:project => Project.find(1), :name => '_') | |
153 |
query.add_filter('subject', '~', [' |
|
153 | query.add_filter('subject', '~', ['uNable']) | |
154 |
assert query.statement.include?("#{Issue.table_name}.subject LIKE '% |
|
154 | assert query.statement.include?("LOWER(#{Issue.table_name}.subject) LIKE '%unable%'") | |
155 | find_issues_with_query(query) |
|
155 | result = find_issues_with_query(query) | |
|
156 | assert result.empty? | |||
|
157 | result.each {|issue| assert issue.subject.downcase.include?('unable') } | |||
156 | end |
|
158 | end | |
157 |
|
159 | |||
158 | def test_operator_does_not_contains |
|
160 | def test_operator_does_not_contains | |
159 | query = Query.new(:project => Project.find(1), :name => '_') |
|
161 | query = Query.new(:project => Project.find(1), :name => '_') | |
160 |
query.add_filter('subject', '!~', [' |
|
162 | query.add_filter('subject', '!~', ['uNable']) | |
161 |
assert query.statement.include?("#{Issue.table_name}.subject NOT LIKE '% |
|
163 | assert query.statement.include?("LOWER(#{Issue.table_name}.subject) NOT LIKE '%unable%'") | |
162 | find_issues_with_query(query) |
|
164 | find_issues_with_query(query) | |
163 | end |
|
165 | end | |
164 |
|
166 |
General Comments 0
You need to be logged in to leave comments.
Login now