@@ -512,11 +512,16 class IssueQuery < Query | |||
|
512 | 512 | end |
|
513 | 513 | |
|
514 | 514 | def sql_for_issue_id_field(field, operator, value) |
|
515 | ids = value.first.to_s.scan(/\d+/).map(&:to_i).join(",") | |
|
516 | if ids.present? | |
|
517 | "#{Issue.table_name}.id IN (#{ids})" | |
|
515 | if operator == "=" | |
|
516 | # accepts a comma separated list of ids | |
|
517 | ids = value.first.to_s.scan(/\d+/).map(&:to_i) | |
|
518 | if ids.present? | |
|
519 | "#{Issue.table_name}.id IN (#{ids.join(",")})" | |
|
520 | else | |
|
521 | "1=0" | |
|
522 | end | |
|
518 | 523 | else |
|
519 | "1=0" | |
|
524 | sql_for_field("id", operator, value, Issue.table_name, "id") | |
|
520 | 525 | end |
|
521 | 526 | end |
|
522 | 527 |
@@ -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