10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/postgres_with/arel/visitors/to_sql.rb', line 10
def collect_ctes(children, collector)
children.each_with_index do |child, i|
collector << ", " unless i == 0
case child
when Arel::Nodes::As, Arel::Nodes::AsMaterialized
name = child.left.name
relation = child.right
when Arel::Nodes::TableAlias
name = child.name
relation = child.relation
end
collector << quote_table_name(name)
if child.class == Arel::Nodes::AsMaterialized
collector << " AS MATERIALIZED "
else
collector << " AS "
end
visit relation, collector
end
collector
end
|