@@ -466,11 +466,16 class IssueQuery < Query | |||
|
466 | 466 | end |
|
467 | 467 | |
|
468 | 468 | def sql_for_issue_id_field(field, operator, value) |
|
469 | ids = value.first.to_s.scan(/\d+/).map(&:to_i).join(",") | |
|
470 | if ids.present? | |
|
471 | "#{Issue.table_name}.id IN (#{ids})" | |
|
469 | if operator == "=" | |
|
470 | # accepts a comma separated list of ids | |
|
471 | ids = value.first.to_s.scan(/\d+/).map(&:to_i) | |
|
472 | if ids.present? | |
|
473 | "#{Issue.table_name}.id IN (#{ids.join(",")})" | |
|
474 | else | |
|
475 | "1=0" | |
|
476 | end | |
|
472 | 477 | else |
|
473 | "1=0" | |
|
478 | sql_for_field("id", operator, value, Issue.table_name, "id") | |
|
474 | 479 | end |
|
475 | 480 | end |
|
476 | 481 |
@@ -235,7 +235,7 class QueryTest < ActiveSupport::TestCase | |||
|
235 | 235 | assert_equal 2, issues.first.id |
|
236 | 236 | end |
|
237 | 237 | |
|
238 |
def test_operator_is_on_i |
|
|
238 | def test_operator_is_on_issue_id_should_accept_comma_separated_values | |
|
239 | 239 | query = IssueQuery.new(:name => '_') |
|
240 | 240 | query.add_filter("issue_id", '=', ['1,3']) |
|
241 | 241 | issues = find_issues_with_query(query) |
@@ -243,6 +243,14 class QueryTest < ActiveSupport::TestCase | |||
|
243 | 243 | assert_equal [1,3], issues.map(&:id).sort |
|
244 | 244 | end |
|
245 | 245 | |
|
246 | def test_operator_between_on_issue_id_should_return_range | |
|
247 | query = IssueQuery.new(:name => '_') | |
|
248 | query.add_filter("issue_id", '><', ['2','3']) | |
|
249 | issues = find_issues_with_query(query) | |
|
250 | assert_equal 2, issues.size | |
|
251 | assert_equal [2,3], issues.map(&:id).sort | |
|
252 | end | |
|
253 | ||
|
246 | 254 | def test_operator_is_on_integer_custom_field |
|
247 | 255 | f = IssueCustomField.create!(:name => 'filter', :field_format => 'int', :is_for_all => true, :is_filter => true, :trackers => Tracker.all) |
|
248 | 256 | CustomValue.create!(:custom_field => f, :customized => Issue.find(1), :value => '7') |
General Comments 0
You need to be logged in to leave comments.
Login now