summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-21 09:37:18 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-21 09:37:18 +0000
commit402d73914634e0e0a2ec06cc94e7b3ec13275546 (patch)
treeb56e8db8860d8b53df074bb570dae65209fa1f0f
parent9c645719ee96b182a2fbe3f77129c1fdb4428791 (diff)
downloadredmine-402d73914634e0e0a2ec06cc94e7b3ec13275546.tar.gz
redmine-402d73914634e0e0a2ec06cc94e7b3ec13275546.zip
Use EXISTS instead of IN subquery (#21608).
Patch by Ondřej Ezr. git-svn-id: http://svn.redmine.org/redmine/trunk@16242 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/project.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index fb2ffc3a6..a09ef781b 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -182,7 +182,7 @@ class Project < ActiveRecord::Base
base_statement = (perm && perm.read? ? "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" : "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}")
if !options[:skip_pre_condition] && perm && perm.project_module
# If the permission belongs to a project module, make sure the module is enabled
- base_statement << " AND #{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.project_module}')"
+ base_statement << " AND EXISTS (SELECT 1 AS one FROM #{EnabledModule.table_name} em WHERE em.project_id = #{Project.table_name}.id AND em.name='#{perm.project_module}')"
end
if project = options[:project]
project_statement = project.project_condition(options[:with_subprojects])