1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# frozen_string_literal: true
module Arel # :nodoc: all
module Visitors
class Informix < Arel::Visitors::ToSql
private
def visit_Arel_Nodes_SelectStatement(o, collector)
collector << "SELECT "
collector = maybe_visit o.offset, collector
collector = maybe_visit o.limit, collector
collector = o.cores.inject(collector) { |c, x|
visit_Arel_Nodes_SelectCore x, c
}
if o.orders.any?
collector << "ORDER BY "
collector = inject_join o.orders, collector, ", "
end
maybe_visit o.lock, collector
end
def visit_Arel_Nodes_SelectCore(o, collector)
collector = inject_join o.projections, collector, ", "
if o.source && !o.source.empty?
collector << " FROM "
collector = visit o.source, collector
end
if o.wheres.any?
collector << " WHERE "
collector = inject_join o.wheres, collector, " AND "
end
if o.groups.any?
collector << "GROUP BY "
collector = inject_join o.groups, collector, ", "
end
if o.havings.any?
collector << " HAVING "
collector = inject_join o.havings, collector, " AND "
end
collector
end
def visit_Arel_Nodes_Offset(o, collector)
collector << "SKIP "
visit o.expr, collector
end
def visit_Arel_Nodes_Limit(o, collector)
collector << "FIRST "
visit o.expr, collector
collector << " "
end
end
end
end
|