Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
d13aebab
Commit
d13aebab
authored
Feb 13, 2018
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace OR clause with UNION.
parent
5048c8d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
app/models/project.rb
app/models/project.rb
+7
-1
No files found.
app/models/project.rb
View file @
d13aebab
...
...
@@ -325,7 +325,13 @@ class Project < ActiveRecord::Base
levels
=
Gitlab
::
VisibilityLevel
.
levels_for_user
(
user
)
where
(
'EXISTS (?) OR projects.visibility_level IN (?)'
,
authorized
,
levels
)
authorized_projects
=
where
(
'EXISTS (?)'
,
authorized
).
select
(
:id
)
visible_projects
=
where
(
'visibility_level IN (?)'
,
levels
).
select
(
:id
)
# We use a UNION here instead of OR clauses since this results in better
# performance.
union
=
Gitlab
::
SQL
::
Union
.
new
([
authorized_projects
,
visible_projects
])
where
(
"projects.id IN (
#{
union
.
to_sql
}
)"
)
# rubocop:disable GitlabSecurity/SqlInjection
else
public_to_user
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment