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