Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
d30e2da7db4b
Commit
68734835
authored
Feb 16, 2018
by
Andreas Brandl
Browse files
Don't mess with table aliases.
parent
c7f9584dbc28
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/models/project.rb
View file @
d30e2da7
...
@@ -337,14 +337,14 @@ def self.public_or_visible_to_user(user = nil, &block)
...
@@ -337,14 +337,14 @@ def self.public_or_visible_to_user(user = nil, &block)
authorized
=
user
authorized
=
user
.
project_authorizations
.
project_authorizations
.
select
(
1
)
.
select
(
1
)
.
where
(
'project_authorizations.project_id = p
1
.id'
)
.
where
(
'project_authorizations.project_id = p
rojects
.id'
)
authorized_projects
=
block
.
call
(
from
(
"
#{
table_name
}
AS p1"
).
where
(
'EXISTS (?)'
,
authorized
))
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
# We use a UNION here instead of OR clauses since this results in better
# performance.
# performance.
union
=
Gitlab
::
SQL
::
Union
.
new
([
authorized_projects
.
select
(
'p
1
.id'
),
visible_projects
.
select
(
'p
2
.id'
)])
union
=
Gitlab
::
SQL
::
Union
.
new
([
authorized_projects
.
select
(
'p
rojects
.id'
),
visible_projects
.
select
(
'p
rojects
.id'
)])
# TODO: from("(#{union.to_sql}) AS #{table_name}")
# TODO: from("(#{union.to_sql}) AS #{table_name}")
where
(
"projects.id IN (
#{
union
.
to_sql
}
)"
)
# rubocop:disable GitlabSecurity/SqlInjection
where
(
"projects.id IN (
#{
union
.
to_sql
}
)"
)
# rubocop:disable GitlabSecurity/SqlInjection
else
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