Commit dfcfc419 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'rails5-fix-6745' into 'master'

Rails5 fix AttachmentRegistryFinder arel queries

Closes #6742, #6745, and #6743

See merge request gitlab-org/gitlab-ee!6396
parents 0a7767e8 be68e0d3
......@@ -103,16 +103,23 @@ module Geo
Namespace.none
end
arel_namespace_ids = Arel::Nodes::SqlLiteral.new(namespace_ids.to_sql)
# This query was intentionally converted to a raw one to get it work in Rails 5.0.
# In Rails 5.0 and 5.1 there's a bug: https://github.com/rails/arel/issues/531
# Please convert it back when on rails 5.2 as it works again as expected since 5.2.
namespace_ids_in_sql = Arel::Nodes::SqlLiteral.new("uploads.model_id IN (#{namespace_ids.to_sql})")
upload_table[:model_type].eq('Namespace').and(upload_table[:model_id].in(arel_namespace_ids))
upload_table[:model_type].eq('Namespace').and(namespace_ids_in_sql)
end
def project_uploads
project_ids = current_node.projects.select(:id)
arel_project_ids = Arel::Nodes::SqlLiteral.new(project_ids.to_sql)
upload_table[:model_type].eq('Project').and(upload_table[:model_id].in(arel_project_ids))
# This query was intentionally converted to a raw one to get it work in Rails 5.0.
# In Rails 5.0 and 5.1 there's a bug: https://github.com/rails/arel/issues/531
# Please convert it back when on rails 5.2 as it works again as expected since 5.2.
project_ids_in_sql = Arel::Nodes::SqlLiteral.new("uploads.model_id IN (#{project_ids.to_sql})")
upload_table[:model_type].eq('Project').and(project_ids_in_sql)
end
def other_uploads
......
---
title: Rails5 fix AttachmentRegistryFinder arel queries
merge_request: 6396
author: Jasper Maes
type: fixed
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment