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 'config/initializers/postgres_cte_as_materialized.rb')
-rw-r--r--config/initializers/postgres_cte_as_materialized.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/config/initializers/postgres_cte_as_materialized.rb b/config/initializers/postgres_cte_as_materialized.rb
new file mode 100644
index 00000000000..85b3361e25e
--- /dev/null
+++ b/config/initializers/postgres_cte_as_materialized.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+# This patch adds support for AS MATERIALIZED in Arel, see Gitlab::Database::AsWithMaterialized for more info
+module Arel
+ module Visitors
+ class Arel::Visitors::PostgreSQL
+ def visit_Gitlab_Database_AsWithMaterialized(obj, collector) # rubocop:disable Naming/MethodName
+ collector = visit obj.left, collector
+ collector << " AS#{obj.expr} "
+ visit obj.right, collector
+ end
+ end
+ end
+end