1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-29 11:49:37 +00:00

Multiple issue ids in "Subtasks" filter (#30808).

Patch by Yuichi HARADA.


git-svn-id: http://svn.redmine.org/redmine/trunk@17908 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2019-02-28 10:01:45 +00:00
parent 8af0990073
commit 40c894ff03
2 changed files with 15 additions and 3 deletions

View File

@ -510,9 +510,11 @@ class IssueQuery < Query
def sql_for_child_id_field(field, operator, value)
case operator
when "="
parent_id = Issue.where(:id => value.first.to_i).pluck(:parent_id).first
if parent_id
"#{Issue.table_name}.id = #{parent_id}"
# accepts a comma separated list of child ids
child_ids = value.first.to_s.scan(/\d+/).map(&:to_i).uniq
ids = Issue.where(:id => child_ids).pluck(:parent_id).compact.uniq
if ids.present?
"#{Issue.table_name}.id IN (#{ids.join(",")})"
else
"1=0"
end

View File

@ -290,6 +290,16 @@ class QueryTest < ActiveSupport::TestCase
assert_equal [2,4,5], issues.map(&:id).sort
end
def test_operator_is_on_child_id_should_accept_comma_separated_values
Issue.where(:id => [2,4]).update_all(:parent_id => 1)
Issue.where(:id => 5).update_all(:parent_id => 3)
query = IssueQuery.new(:name => '_')
query.add_filter("child_id", '=', ['2,4,5'])
issues = find_issues_with_query(query)
assert_equal 2, issues.size
assert_equal [1,3], issues.map(&:id).sort
end
def test_operator_between_on_issue_id_should_return_range
query = IssueQuery.new(:name => '_')
query.add_filter("issue_id", '><', ['2','3'])