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
78d84c13
Commit
78d84c13
authored
Feb 16, 2018
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't mess with table aliases.
parent
86591b83
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
app/models/project.rb
app/models/project.rb
+4
-4
No files found.
app/models/project.rb
View file @
78d84c13
...
...
@@ -337,14 +337,14 @@ class Project < ActiveRecord::Base
authorized
=
user
.
project_authorizations
.
select
(
1
)
.
where
(
'project_authorizations.project_id = p
1
.id'
)
authorized_projects
=
block
.
call
(
from
(
"
#{
table_name
}
AS p1"
).
where
(
'EXISTS (?)'
,
authorized
))
.
where
(
'project_authorizations.project_id = p
rojects
.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
(
'p
1.id'
),
visible_projects
.
select
(
'p2
.id'
)])
union
=
Gitlab
::
SQL
::
Union
.
new
([
authorized_projects
.
select
(
'p
rojects.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
...
...
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