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