Skip to content

Commit

Permalink
Implement name function for SqlLiteral to allow Rails 6.1 to process …
Browse files Browse the repository at this point in the history
…CTE's
  • Loading branch information
GeorgeKaraszi committed Dec 18, 2020
1 parent f85ff8e commit 5e29faa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/active_record_extended/arel.rb
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 16 additions & 0 deletions lib/active_record_extended/arel/sql_literal.rb
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 0 additions & 10 deletions lib/active_record_extended/arel/visitors/postgresql_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5e29faa

Please sign in to comment.