diff --git a/lib/active_record_extended/arel.rb b/lib/active_record_extended/arel.rb index 18beb8d..8aab9ac 100644 --- a/lib/active_record_extended/arel.rb +++ b/lib/active_record_extended/arel.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "active_record_extended/arel/nodes" +require "active_record_extended/arel/sql_literal" require "active_record_extended/arel/aggregate_function_name" require "active_record_extended/arel/predications" require "active_record_extended/arel/visitors/postgresql_decorator" diff --git a/lib/active_record_extended/arel/sql_literal.rb b/lib/active_record_extended/arel/sql_literal.rb new file mode 100644 index 0000000..f485644 --- /dev/null +++ b/lib/active_record_extended/arel/sql_literal.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require "arel/nodes/sql_literal" + +# CTE alias fix for Rails 6.1 +module Arel + module Nodes + module SqlLiteralDecorator + def name + self + end + end + end +end + +Arel::Nodes::SqlLiteral.prepend(Arel::Nodes::SqlLiteralDecorator) diff --git a/lib/active_record_extended/arel/visitors/postgresql_decorator.rb b/lib/active_record_extended/arel/visitors/postgresql_decorator.rb index eb57141..289f18f 100644 --- a/lib/active_record_extended/arel/visitors/postgresql_decorator.rb +++ b/lib/active_record_extended/arel/visitors/postgresql_decorator.rb @@ -75,16 +75,6 @@ def visit_Arel_Nodes_ArrayAgg(object, collector) aggregate "ARRAY_AGG", object, collector end - def visit_Arel_Nodes_With(o, collector) - collector << "WITH " - inject_join o.children, collector, ", " - end - - def visit_Arel_Nodes_WithRecursive(o, collector) - collector << "WITH RECURSIVE " - inject_join o.children, collector, ", " - end - def visit_Arel_Nodes_AggregateFunctionName(object, collector) collector << "#{object.name}(" collector << "DISTINCT " if object.distinct