summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2023-11-11 06:00:20 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2023-11-11 06:00:20 +0000
commit98fa89400e5694ae618963f72c2bba5402fd5c4a (patch)
treedb7a671f226d825834a62a42da204eccde1c84cb /app/models
parentf0f1d49b565a541a1c9d9df149fc0db7a0d3650e (diff)
downloadredmine-98fa89400e5694ae618963f72c2bba5402fd5c4a.tar.gz
redmine-98fa89400e5694ae618963f72c2bba5402fd5c4a.zip
Fix an expression of non-boolean type specified in a context where a condition is expected when MSSQL is used (#39443).
Patch by Pavel Rosický. git-svn-id: https://svn.redmine.org/redmine/trunk@22417 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/issue_query.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index 235bf2fbe..9e1e1c432 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -566,11 +566,12 @@ class IssueQuery < Query
when "*", "!*" # Member / Not member
sw = operator == "!*" ? 'NOT' : ''
nl = operator == "!*" ? "#{Issue.table_name}.assigned_to_id IS NULL OR" : ''
+
subquery =
- "SELECT DISTINCT #{Member.table_name}.user_id" +
+ "SELECT 1" +
" FROM #{Member.table_name}" +
- " WHERE #{Member.table_name}.project_id = #{Issue.table_name}.project_id"
- "(#{nl} #{Issue.table_name}.assigned_to_id #{sw} IN (#{subquery}))"
+ " WHERE #{Issue.table_name}.project_id = #{Member.table_name}.project_id AND #{Member.table_name}.user_id = #{Issue.table_name}.assigned_to_id"
+ "(#{nl} #{sw} EXISTS (#{subquery}))"
when "=", "!"
role_cond =
if value.any?
@@ -581,10 +582,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, #{Member.table_name}.project_id" +
- " FROM #{Member.table_name}, #{MemberRole.table_name}" +
- " 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}))"
+ "SELECT 1" +
+ " FROM #{Member.table_name} inner join #{MemberRole.table_name} on members.id = member_roles.member_id" +
+ " WHERE #{Issue.table_name}.project_id = #{Member.table_name}.project_id AND #{Member.table_name}.user_id = #{Issue.table_name}.assigned_to_id AND #{role_cond}"
+ "(#{nl} #{sw} EXISTS (#{subquery}))"
end
end