summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-02-16 22:19:41 +0100
committerAndreas Brandl <abrandl@gitlab.com>2018-02-20 13:08:25 +0100
commit78d84c13c0cf8a9ed3f92239ef8ba8e9a05609a2 (patch)
tree08e7cfd2ff05a678a8c207e4023d4d47ecec3809
parent86591b83501060583fa7c8373faa8986ec4f30f3 (diff)
downloadgitlab-ce-78d84c13c0cf8a9ed3f92239ef8ba8e9a05609a2.tar.gz
Don't mess with table aliases.
-rw-r--r--app/models/project.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 14bc2185d1b..5c6088d120f 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -337,14 +337,14 @@ class Project < ActiveRecord::Base
authorized = user
.project_authorizations
.select(1)
- .where('project_authorizations.project_id = p1.id')
- authorized_projects = block.call(from("#{table_name} AS p1").where('EXISTS (?)', authorized))
+ .where('project_authorizations.project_id = projects.id')
+ authorized_projects = block.call(where('EXISTS (?)', authorized))
- visible_projects = block.call(from("#{table_name} AS p2").where('visibility_level IN (?)', levels))
+ visible_projects = block.call(where('visibility_level IN (?)', levels))
# We use a UNION here instead of OR clauses since this results in better
# performance.
- union = Gitlab::SQL::Union.new([authorized_projects.select('p1.id'), visible_projects.select('p2.id')])
+ union = Gitlab::SQL::Union.new([authorized_projects.select('projects.id'), visible_projects.select('projects.id')])
# TODO: from("(#{union.to_sql}) AS #{table_name}")
where("projects.id IN (#{union.to_sql})") # rubocop:disable GitlabSecurity/SqlInjection
else