diff options
Diffstat (limited to 'app/models/preloaders/user_max_access_level_in_projects_preloader.rb')
-rw-r--r-- | app/models/preloaders/user_max_access_level_in_projects_preloader.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/preloaders/user_max_access_level_in_projects_preloader.rb b/app/models/preloaders/user_max_access_level_in_projects_preloader.rb index 2e2272a2ef5..c9fd5e7718a 100644 --- a/app/models/preloaders/user_max_access_level_in_projects_preloader.rb +++ b/app/models/preloaders/user_max_access_level_in_projects_preloader.rb @@ -7,9 +7,11 @@ module Preloaders def initialize(projects, user) @projects = if projects.is_a?(Array) Project.where(id: projects) - else + elsif Feature.enabled?(:projects_preloader_fix) # Push projects base query in to a sub-select to avoid # table name clashes. Performs better than aliasing. + Project.where(id: projects.subquery(:id)) + else Project.where(id: projects.reselect(:id)) end @@ -17,6 +19,8 @@ module Preloaders end def execute + return unless @user + project_authorizations = ProjectAuthorization.arel_table auths = @projects |