mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-11 01:51:32 +00:00
Multiple issue ids in "Parent task" filter (#30482).
Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@17843 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f65f1d37bf
commit
aca80173b6
@ -486,7 +486,13 @@ class IssueQuery < Query
|
||||
def sql_for_parent_id_field(field, operator, value)
|
||||
case operator
|
||||
when "="
|
||||
"#{Issue.table_name}.parent_id = #{value.first.to_i}"
|
||||
# accepts a comma separated list of ids
|
||||
ids = value.first.to_s.scan(/\d+/).map(&:to_i).uniq
|
||||
if ids.present?
|
||||
"#{Issue.table_name}.parent_id IN (#{ids.join(",")})"
|
||||
else
|
||||
"1=0"
|
||||
end
|
||||
when "~"
|
||||
root_id, lft, rgt = Issue.where(:id => value.first.to_i).pluck(:root_id, :lft, :rgt).first
|
||||
if root_id && lft && rgt
|
||||
|
||||
@ -280,6 +280,16 @@ class QueryTest < ActiveSupport::TestCase
|
||||
assert_equal [1,3], issues.map(&:id).sort
|
||||
end
|
||||
|
||||
def test_operator_is_on_parent_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("parent_id", '=', ['1,3'])
|
||||
issues = find_issues_with_query(query)
|
||||
assert_equal 3, issues.size
|
||||
assert_equal [2,4,5], 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'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user