Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/sql/set_operator.rb')
-rw-r--r--lib/gitlab/sql/set_operator.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/gitlab/sql/set_operator.rb b/lib/gitlab/sql/set_operator.rb
index 18275da3ef0..8b4c43786f7 100644
--- a/lib/gitlab/sql/set_operator.rb
+++ b/lib/gitlab/sql/set_operator.rb
@@ -35,9 +35,12 @@ module Gitlab
# By using "unprepared_statements" we remove the usage of placeholders
# (thus fixing this problem), at a slight performance cost.
fragments = ApplicationRecord.connection.unprepared_statement do
- relations.map do |rel|
- remove_order ? rel.reorder(nil).to_sql : rel.to_sql
- end.reject(&:blank?)
+ relations.filter_map do |rel|
+ next if rel.is_a?(ActiveRecord::NullRelation)
+
+ sql = remove_order ? rel.reorder(nil).to_sql : rel.to_sql
+ sql.presence
+ end
end
if fragments.any?