arel_extensions 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors/oracle12.rb +51 -54
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8255cb9ebee4b9aded4f23486b0ef143651fecc
|
4
|
+
data.tar.gz: 5d45081246d1b3221d2e29c6f55b39ba886b20cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81631cd7e514add0be52d774c9be37c22dfa8304d73eb9ba79fd4b5b034eb69e9c1f8c7e40a18ee34183a34c5b0d86bca118c34cc76bba2765bca2886cebc858
|
7
|
+
data.tar.gz: afa3c43c1ec75118dc8c2ee24973973872a7b291b938e6a8a4cd9554c099c4abe067eb9d59f9b1d79f16946548f6b25ac1e01ea540caf7008c90d7240a5da59f
|
@@ -1,68 +1,65 @@
|
|
1
1
|
module ArelExtensions
|
2
|
-
module Visitors
|
3
|
-
|
4
|
-
class Arel::Visitors::Oracle12 < Arel::Visitors::Oracle
|
5
|
-
|
2
|
+
module Visitors
|
3
|
+
class Arel::Visitors::Oracle12 < Arel::Visitors::Oracle
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
def visit_Arel_Nodes_SelectStatement(o, collector)
|
6
|
+
# Oracle does not allow LIMIT clause with select for update
|
7
|
+
if o.limit && o.lock
|
8
|
+
raise ArgumentError, <<-MSG
|
9
|
+
'Combination of limit and lock is not supported.
|
10
|
+
because generated SQL statements
|
11
|
+
`SELECT FOR UPDATE and FETCH FIRST n ROWS` generates ORA-02014.`
|
12
|
+
MSG
|
13
|
+
end
|
14
|
+
super
|
15
|
+
end
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
def visit_Arel_Nodes_SelectOptions(o, collector)
|
18
|
+
collector = maybe_visit o.offset, collector
|
19
|
+
collector = maybe_visit o.limit, collector
|
20
|
+
maybe_visit o.lock, collector
|
21
|
+
end
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
def visit_Arel_Nodes_Limit(o, collector)
|
24
|
+
collector << "FETCH FIRST "
|
25
|
+
collector = visit o.expr, collector
|
26
|
+
collector << " ROWS ONLY"
|
27
|
+
end
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
def visit_Arel_Nodes_Offset(o, collector)
|
30
|
+
collector << "OFFSET "
|
31
|
+
visit o.expr, collector
|
32
|
+
collector << " ROWS"
|
33
|
+
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
def visit_Arel_Nodes_Except(o, collector)
|
36
|
+
collector << "( "
|
37
|
+
collector = infix_value o, collector, " MINUS "
|
38
|
+
collector << " )"
|
39
|
+
end
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
def visit_Arel_Nodes_UpdateStatement(o, collector)
|
42
|
+
# Oracle does not allow ORDER BY/LIMIT in UPDATEs.
|
43
|
+
if o.orders.any? && o.limit.nil?
|
44
|
+
# However, there is no harm in silently eating the ORDER BY clause if no LIMIT has been provided,
|
45
|
+
# otherwise let the user deal with the error
|
46
|
+
o = o.dup
|
47
|
+
o.orders = []
|
48
|
+
end
|
51
49
|
|
52
|
-
|
53
|
-
|
50
|
+
super
|
51
|
+
end
|
54
52
|
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
def visit_Arel_Nodes_BindParam(o, collector)
|
54
|
+
collector.add_bind(o.value) { |i| ":a#{i}" }
|
55
|
+
end
|
58
56
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
def is_distinct_from(o, collector)
|
58
|
+
collector << "DECODE("
|
59
|
+
collector = visit [o.left, o.right, 0, 1], collector
|
60
|
+
collector << ")"
|
61
|
+
end
|
64
62
|
|
65
|
-
end
|
66
63
|
end
|
67
64
|
end
|
68
65
|
end
|