From bfe619ae7e531db8a003f4a623ff29f120ac0755 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Mon, 9 Oct 2023 05:30:04 +0000 Subject: [PATCH] Optimize IssueQuery#sql_for_assigned_to_role_field for PostgreSQL (#38319). Contributed by Vincent Robert. git-svn-id: https://svn.redmine.org/redmine/trunk@22334 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue_query.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 672785cc1..235bf2fbe 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -581,10 +581,10 @@ class IssueQuery < Query sw = operator == "!" ? 'NOT' : '' nl = operator == "!" ? "#{Issue.table_name}.assigned_to_id IS NULL OR" : '' subquery = - "SELECT DISTINCT #{Member.table_name}.user_id" + + "SELECT DISTINCT #{Member.table_name}.user_id, #{Member.table_name}.project_id" + " FROM #{Member.table_name}, #{MemberRole.table_name}" + - " WHERE #{Member.table_name}.project_id = #{Issue.table_name}.project_id AND #{Member.table_name}.id = #{MemberRole.table_name}.member_id AND #{role_cond}" - "(#{nl} #{Issue.table_name}.assigned_to_id #{sw} IN (#{subquery}))" + " WHERE #{Member.table_name}.id = #{MemberRole.table_name}.member_id AND #{role_cond}" + "(#{nl} (#{Issue.table_name}.assigned_to_id, #{Issue.table_name}.project_id) #{sw} IN (#{subquery}))" end end -- 2.39.5