summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-12-29 08:24:43 +0000
committerGo MAEDA <maeda@farend.jp>2023-12-29 08:24:43 +0000
commit13028b913b56eb4b5a7007ea5eea65ea2b19828e (patch)
tree2bde62b1fcb23297c66182b6048ba05e5ad9368c /app
parentf02e2c088bf902f20a21d563f49f426bc063de25 (diff)
downloadredmine-13028b913b56eb4b5a7007ea5eea65ea2b19828e.tar.gz
redmine-13028b913b56eb4b5a7007ea5eea65ea2b19828e.zip
Extend "contains" operator in "Parent task" filter to support multiple issue IDs (#39805).
Patch by Go MAEDA (@maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@22577 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/issue_query.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index b18117cc9..21552dfd6 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -662,9 +662,18 @@ class IssueQuery < Query
"1=0"
end
when "~"
- root_id, lft, rgt = Issue.where(:id => value.first.to_i).pick(:root_id, :lft, :rgt)
- if root_id && lft && rgt
- "#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft > #{lft} AND #{Issue.table_name}.rgt < #{rgt}"
+ ids = value.first.to_s.scan(/\d+/).map(&:to_i).uniq
+ conditions = ids.filter_map do |id|
+ root_id, lft, rgt = Issue.where(id: id).pick(:root_id, :lft, :rgt)
+ if root_id && lft && rgt
+ "(#{Issue.table_name}.root_id = #{root_id} AND #{Issue.table_name}.lft > #{lft} AND #{Issue.table_name}.rgt < #{rgt})"
+ else
+ nil
+ end
+ end
+
+ if conditions.any?
+ "(#{conditions.join(' OR ')})"
else
"1=0"
end