oracle-sql-parser 0.3.1 → 0.4.0
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/README.md +10 -0
- data/lib/oracle-sql-parser.rb +1 -0
- data/lib/oracle-sql-parser/ast.rb +14 -1
- data/lib/oracle-sql-parser/ast/base.rb +1 -0
- data/lib/oracle-sql-parser/ast/cross_natural_join_clause.rb +8 -0
- data/lib/oracle-sql-parser/ast/floating_point_condition.rb +7 -0
- data/lib/oracle-sql-parser/ast/inner_cross_join_clause.rb +7 -0
- data/lib/oracle-sql-parser/ast/inner_join_clause.rb +8 -0
- data/lib/oracle-sql-parser/ast/is_a_set_condition.rb +7 -0
- data/lib/oracle-sql-parser/ast/is_empty_condition.rb +7 -0
- data/lib/oracle-sql-parser/ast/is_of_type_condition.rb +14 -0
- data/lib/oracle-sql-parser/ast/member_condition.rb +9 -0
- data/lib/oracle-sql-parser/ast/on_clause.rb +7 -0
- data/lib/oracle-sql-parser/ast/only_and_type.rb +7 -0
- data/lib/oracle-sql-parser/ast/outer_join_clause.rb +12 -0
- data/lib/oracle-sql-parser/ast/submultiset_condition.rb +8 -0
- data/lib/oracle-sql-parser/ast/subquery.rb +18 -0
- data/lib/oracle-sql-parser/ast/using_clause.rb +10 -0
- data/lib/oracle-sql-parser/grammar/condition.treetop +138 -8
- data/lib/oracle-sql-parser/grammar/reserved_word_generator.rb +7 -0
- data/lib/oracle-sql-parser/grammar/select.treetop +166 -45
- data/lib/oracle-sql-parser/version.rb +1 -1
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a018b591726cc7ed741116975e8e1b584290ecdb
|
4
|
+
data.tar.gz: af228b7b9f8c1d968741be535a3608c1769f0275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 965fcce0d33993a725e371160860a696c9064969bddcf851cc04e77dca7e9b7a5326cead6c05a0cdd2a860b9e5aa24f49ddef04005b7e283d2d97ce214990d54
|
7
|
+
data.tar.gz: b98665f5a7b3074f6e5dd7f7b00a132a7fed6edc407d7962feaa01cbfb28e88441ffb35bf70c8c4873312be74b3926ed840edc4755e326870eb634a017144cb2
|
data/README.md
CHANGED
@@ -58,6 +58,16 @@ ast.to_sql
|
|
58
58
|
=> "select 1 from dual"
|
59
59
|
</pre>
|
60
60
|
|
61
|
+
```ruby
|
62
|
+
p = ast.to_parameternized
|
63
|
+
p.to_sql
|
64
|
+
p.params.inspect
|
65
|
+
```
|
66
|
+
<pre>
|
67
|
+
=> "select :a0 from dual"
|
68
|
+
=> {"a0"=>#<OracleSqlParser::Ast::NumberLiteral {:value=>"1"}>}
|
69
|
+
</pre>
|
70
|
+
|
61
71
|
## Contributing
|
62
72
|
|
63
73
|
Bug reports and pull requests are welcome on GitHub at https://github.com/jksy/sql_parser.
|
data/lib/oracle-sql-parser.rb
CHANGED
@@ -9,6 +9,12 @@ require 'oracle-sql-parser/ast/hash.rb'
|
|
9
9
|
require 'oracle-sql-parser/ast/select_statement.rb'
|
10
10
|
require 'oracle-sql-parser/ast/subquery.rb'
|
11
11
|
require 'oracle-sql-parser/ast/query_block.rb'
|
12
|
+
require 'oracle-sql-parser/ast/inner_cross_join_clause.rb'
|
13
|
+
require 'oracle-sql-parser/ast/inner_join_clause.rb'
|
14
|
+
require 'oracle-sql-parser/ast/outer_join_clause.rb'
|
15
|
+
require 'oracle-sql-parser/ast/on_clause.rb'
|
16
|
+
require 'oracle-sql-parser/ast/using_clause.rb'
|
17
|
+
require 'oracle-sql-parser/ast/cross_natural_join_clause.rb'
|
12
18
|
require 'oracle-sql-parser/ast/where_clause.rb'
|
13
19
|
require 'oracle-sql-parser/ast/simple_comparision_condition.rb'
|
14
20
|
require 'oracle-sql-parser/ast/logical_condition.rb'
|
@@ -18,6 +24,14 @@ require 'oracle-sql-parser/ast/null_condition.rb'
|
|
18
24
|
require 'oracle-sql-parser/ast/between_condition.rb'
|
19
25
|
require 'oracle-sql-parser/ast/exists_condition.rb'
|
20
26
|
require 'oracle-sql-parser/ast/in_condition.rb'
|
27
|
+
require 'oracle-sql-parser/ast/compound_condition.rb'
|
28
|
+
require 'oracle-sql-parser/ast/floating_point_condition.rb'
|
29
|
+
require 'oracle-sql-parser/ast/is_a_set_condition.rb'
|
30
|
+
require 'oracle-sql-parser/ast/is_empty_condition.rb'
|
31
|
+
require 'oracle-sql-parser/ast/member_condition.rb'
|
32
|
+
require 'oracle-sql-parser/ast/submultiset_condition.rb'
|
33
|
+
require 'oracle-sql-parser/ast/is_of_type_condition.rb'
|
34
|
+
require 'oracle-sql-parser/ast/only_and_type.rb'
|
21
35
|
require 'oracle-sql-parser/ast/group_by_clause.rb'
|
22
36
|
require 'oracle-sql-parser/ast/rollup_cube_clause.rb'
|
23
37
|
require 'oracle-sql-parser/ast/for_update_clause.rb'
|
@@ -38,6 +52,5 @@ require 'oracle-sql-parser/ast/identifier.rb'
|
|
38
52
|
require 'oracle-sql-parser/ast/text_literal.rb'
|
39
53
|
require 'oracle-sql-parser/ast/number_literal.rb'
|
40
54
|
require 'oracle-sql-parser/ast/table_reference.rb'
|
41
|
-
require 'oracle-sql-parser/ast/compound_condition.rb'
|
42
55
|
require 'oracle-sql-parser/ast/variable.rb'
|
43
56
|
require 'oracle-sql-parser/ast/keyword.rb'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module OracleSqlParser::Ast
|
2
|
+
class IsOfTypeCondition < Hash
|
3
|
+
def to_sql(options = {})
|
4
|
+
[
|
5
|
+
@ast[:target],
|
6
|
+
@ast[:is],
|
7
|
+
@ast[:not],
|
8
|
+
@ast[:of],
|
9
|
+
@ast[:type],
|
10
|
+
"(#{@ast[:types].map(&:to_sql).join(',')})",
|
11
|
+
].compact.map(&:to_sql).join(' ')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module OracleSqlParser::Ast
|
2
|
+
class OuterJoinClause < Hash
|
3
|
+
def table1=(value)
|
4
|
+
@ast[:table1] = value
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_sql
|
8
|
+
@ast.values_at(:table1, :natural, :join_type, :outer, :join, :table2, :on_or_using_clause).
|
9
|
+
compact.map(&:to_sql).join(' ')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,5 +1,23 @@
|
|
1
1
|
module OracleSqlParser::Ast
|
2
2
|
class Subquery < Hash
|
3
|
+
def to_sql(options = {})
|
4
|
+
if @ast[:union]
|
5
|
+
[
|
6
|
+
@ast[:query_block1],
|
7
|
+
@ast[:union].map(&:to_sql).join(' '),
|
8
|
+
@ast[:query_block2],
|
9
|
+
@ast[:order_by_clause],
|
10
|
+
].compact.map(&:to_sql).join(' ')
|
11
|
+
else
|
12
|
+
[
|
13
|
+
@ast[:query_block],
|
14
|
+
@ast[:order_by_clause]
|
15
|
+
].compact.map(&:to_sql).join(' ')
|
16
|
+
end
|
17
|
+
end
|
3
18
|
|
19
|
+
def order_by_clause=(value)
|
20
|
+
@ast[:order_by_clause] = value
|
21
|
+
end
|
4
22
|
end
|
5
23
|
end
|
@@ -15,7 +15,6 @@ module OracleSqlParser::Grammar
|
|
15
15
|
model_condition /
|
16
16
|
mutiset_condition /
|
17
17
|
pattern_maching_condition /
|
18
|
-
range_condition /
|
19
18
|
null_condition /
|
20
19
|
xml_condition /
|
21
20
|
compound_condition /
|
@@ -85,7 +84,20 @@ module OracleSqlParser::Grammar
|
|
85
84
|
end
|
86
85
|
|
87
86
|
rule floating_point_condition
|
88
|
-
|
87
|
+
expr space? is_keyword space? not_keyword:not_keyword? space?
|
88
|
+
value:(
|
89
|
+
nan_keyword /
|
90
|
+
infinite_keyword
|
91
|
+
) {
|
92
|
+
def ast
|
93
|
+
OracleSqlParser::Ast::FloatingPointCondition[
|
94
|
+
:target => expr.ast,
|
95
|
+
:is => is_keyword.ast,
|
96
|
+
:not => not_keyword.ast,
|
97
|
+
:value => value.ast
|
98
|
+
]
|
99
|
+
end
|
100
|
+
}
|
89
101
|
end
|
90
102
|
|
91
103
|
rule model_condition
|
@@ -93,7 +105,81 @@ module OracleSqlParser::Grammar
|
|
93
105
|
end
|
94
106
|
|
95
107
|
rule mutiset_condition
|
96
|
-
|
108
|
+
is_a_set_condition /
|
109
|
+
is_empty_condition /
|
110
|
+
member_condition /
|
111
|
+
submultiset_condition {
|
112
|
+
def ast
|
113
|
+
super
|
114
|
+
end
|
115
|
+
}
|
116
|
+
end
|
117
|
+
|
118
|
+
rule nested_table
|
119
|
+
ident {
|
120
|
+
def ast
|
121
|
+
super
|
122
|
+
end
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
rule is_a_set_condition
|
127
|
+
nested_table space? is_keyword space? not_keyword:not_keyword? space? a:[Aa] space? set_keyword {
|
128
|
+
def ast
|
129
|
+
OracleSqlParser::Ast::IsASetCondition[
|
130
|
+
:target => nested_table.ast,
|
131
|
+
:is => is_keyword.ast,
|
132
|
+
:not => not_keyword.ast,
|
133
|
+
:a => OracleSqlParser::Ast::Keyword[:name => a.text_value],
|
134
|
+
:set => set_keyword.ast
|
135
|
+
]
|
136
|
+
end
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
rule is_empty_condition
|
141
|
+
nested_table space? is_keyword space? not_keyword:not_keyword? space? empty_keyword {
|
142
|
+
def ast
|
143
|
+
OracleSqlParser::Ast::IsEmptyCondition[
|
144
|
+
:target => nested_table.ast,
|
145
|
+
:is => is_keyword.ast,
|
146
|
+
:not => not_keyword.ast,
|
147
|
+
:empty => empty_keyword.ast
|
148
|
+
]
|
149
|
+
end
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
153
|
+
rule member_condition
|
154
|
+
expr space? not_keyword:not_keyword? space? member_keyword space? of_keyword space? nested_table {
|
155
|
+
def ast
|
156
|
+
OracleSqlParser::Ast::MemberCondition[
|
157
|
+
:target => expr.ast,
|
158
|
+
:not => not_keyword.ast,
|
159
|
+
:member => member_keyword.ast,
|
160
|
+
:of => of_keyword.ast,
|
161
|
+
:table => nested_table.ast
|
162
|
+
]
|
163
|
+
end
|
164
|
+
}
|
165
|
+
end
|
166
|
+
|
167
|
+
rule submultiset_condition
|
168
|
+
table1:nested_table space?
|
169
|
+
not_keyword:not_keyword? space?
|
170
|
+
submultiset_keyword space?
|
171
|
+
of_keyword:of_keyword? space?
|
172
|
+
table2:nested_table {
|
173
|
+
def ast
|
174
|
+
OracleSqlParser::Ast::SubmultisetCondition[
|
175
|
+
:target => table1.ast,
|
176
|
+
:not => not_keyword.ast,
|
177
|
+
:submultiset => submultiset_keyword.ast,
|
178
|
+
:of => of_keyword.ast,
|
179
|
+
:table => table2.ast
|
180
|
+
]
|
181
|
+
end
|
182
|
+
}
|
97
183
|
end
|
98
184
|
|
99
185
|
rule pattern_maching_condition
|
@@ -144,10 +230,6 @@ module OracleSqlParser::Grammar
|
|
144
230
|
}
|
145
231
|
end
|
146
232
|
|
147
|
-
rule range_condition
|
148
|
-
'range_condition'
|
149
|
-
end
|
150
|
-
|
151
233
|
rule null_condition
|
152
234
|
expr space is_keyword space n:(not_keyword space)? null_keyword {
|
153
235
|
def ast
|
@@ -218,7 +300,55 @@ module OracleSqlParser::Grammar
|
|
218
300
|
end
|
219
301
|
|
220
302
|
rule is_of_type_condition
|
221
|
-
|
303
|
+
expr space?
|
304
|
+
is_keyword space?
|
305
|
+
not_keyword:not_keyword? space?
|
306
|
+
of_keyword space?
|
307
|
+
type_keyword:type_keyword? space?
|
308
|
+
'(' space? types space? ')' {
|
309
|
+
def ast
|
310
|
+
OracleSqlParser::Ast::IsOfTypeCondition[
|
311
|
+
:target => expr.ast,
|
312
|
+
:is => is_keyword.ast,
|
313
|
+
:not => not_keyword.ast,
|
314
|
+
:of => of_keyword.ast,
|
315
|
+
:type => type_keyword.ast,
|
316
|
+
:types => types.ast
|
317
|
+
]
|
318
|
+
end
|
319
|
+
}
|
320
|
+
end
|
321
|
+
|
322
|
+
rule types
|
323
|
+
only_and_type space? more:(',' space? only_and_type space?)* {
|
324
|
+
def ast
|
325
|
+
OracleSqlParser::Ast::Array[only_and_type.ast, *more_only_and_types.map(&:ast)]
|
326
|
+
end
|
327
|
+
|
328
|
+
def more_only_and_types
|
329
|
+
more.elements.map(&:only_and_type)
|
330
|
+
end
|
331
|
+
}
|
332
|
+
end
|
333
|
+
|
334
|
+
rule only_and_type
|
335
|
+
only_keyword:only_keyword? space? type {
|
336
|
+
def ast
|
337
|
+
OracleSqlParser::Ast::OnlyAndType[
|
338
|
+
:only => only_keyword.ast,
|
339
|
+
:type => type.ast
|
340
|
+
]
|
341
|
+
end
|
342
|
+
}
|
343
|
+
end
|
344
|
+
|
345
|
+
rule type
|
346
|
+
schema_name '.' ident /
|
347
|
+
ident {
|
348
|
+
def ast
|
349
|
+
OracleSqlParser::Ast::Identifier[:name => text_value]
|
350
|
+
end
|
351
|
+
}
|
222
352
|
end
|
223
353
|
end
|
224
354
|
end
|
@@ -120,6 +120,7 @@ EOS
|
|
120
120
|
'DISTINCT',
|
121
121
|
'DROP',
|
122
122
|
'ELSE',
|
123
|
+
'EMPTY',
|
123
124
|
'END',
|
124
125
|
'ESCAPE',
|
125
126
|
'EXCLUSIVE',
|
@@ -138,6 +139,7 @@ EOS
|
|
138
139
|
'IN',
|
139
140
|
'INCREMENT',
|
140
141
|
'INDEX',
|
142
|
+
'INFINITE',
|
141
143
|
'INITIAL',
|
142
144
|
'INNER',
|
143
145
|
'INSERT',
|
@@ -156,10 +158,12 @@ EOS
|
|
156
158
|
'LOCK',
|
157
159
|
'LONG',
|
158
160
|
'MAXEXTENTS',
|
161
|
+
'MEMBER',
|
159
162
|
'MINUS',
|
160
163
|
'MLSLABEL',
|
161
164
|
'MODE',
|
162
165
|
'MODIFY',
|
166
|
+
'NAN',
|
163
167
|
'NATURAL',
|
164
168
|
'NESTED_TABLE_ID',
|
165
169
|
'NEXTVAL',
|
@@ -174,6 +178,7 @@ EOS
|
|
174
178
|
'OFFLINE',
|
175
179
|
'ON',
|
176
180
|
'ONLINE',
|
181
|
+
'ONLY',
|
177
182
|
'OPTION',
|
178
183
|
'OR',
|
179
184
|
'ORDER',
|
@@ -201,6 +206,7 @@ EOS
|
|
201
206
|
'SIBLINGS',
|
202
207
|
'SMALLINT',
|
203
208
|
'START',
|
209
|
+
'SUBMULTISET',
|
204
210
|
'SUCCESSFUL',
|
205
211
|
'SYNONYM',
|
206
212
|
'SYSDATE',
|
@@ -209,6 +215,7 @@ EOS
|
|
209
215
|
'THEN',
|
210
216
|
'TO',
|
211
217
|
'TRIGGER',
|
218
|
+
'TYPE',
|
212
219
|
'UID',
|
213
220
|
'UNION',
|
214
221
|
'UNIQUE',
|
@@ -11,18 +11,68 @@ module OracleSqlParser::Grammar
|
|
11
11
|
end
|
12
12
|
|
13
13
|
rule subquery
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
query:(
|
15
|
+
subquery_with_union /
|
16
|
+
subquery_only_query_block
|
17
|
+
)
|
18
|
+
space? order_by_clause:order_by_clause? {
|
19
|
+
def ast
|
20
|
+
result = query.ast
|
21
|
+
result.order_by_clause = order_by_clause.ast
|
22
|
+
result
|
23
|
+
end
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
rule subquery_only_query_block
|
28
|
+
'(' space? query_block:query_block space? ')' /
|
29
|
+
query_block:query_block {
|
22
30
|
def ast
|
23
31
|
OracleSqlParser::Ast::Subquery[
|
24
|
-
:query_block => query_block.ast
|
25
|
-
|
32
|
+
:query_block => query_block.ast
|
33
|
+
]
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
rule subquery_with_union
|
39
|
+
'(' query_block1:query_block space? union_or_intersect_or_minus space? query_block2:query_block ')' /
|
40
|
+
query_block1:query_block space? union_or_intersect_or_minus space? query_block2:query_block {
|
41
|
+
def ast
|
42
|
+
OracleSqlParser::Ast::Subquery[
|
43
|
+
:query_block1 => query_block1.ast,
|
44
|
+
:union => union_or_intersect_or_minus.ast,
|
45
|
+
:query_block2 => query_block2.ast
|
46
|
+
]
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
rule union_or_intersect_or_minus
|
52
|
+
(
|
53
|
+
union:union_all /
|
54
|
+
intersect:intersect_keyword /
|
55
|
+
minus:minus_keyword
|
56
|
+
) {
|
57
|
+
def ast
|
58
|
+
if respond_to? :union
|
59
|
+
union.ast
|
60
|
+
elsif respond_to? :intersect
|
61
|
+
OracleSqlParser::Ast::Array[intersect.ast]
|
62
|
+
elsif respond_to? :minus
|
63
|
+
OracleSqlParser::Ast::Array[minus.ast]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
rule union_all
|
70
|
+
union_keyword all:(space all_keyword)? {
|
71
|
+
def ast
|
72
|
+
OracleSqlParser::Ast::Array[
|
73
|
+
union_keyword.ast,
|
74
|
+
all.try(:all_keyword).ast
|
75
|
+
]
|
26
76
|
end
|
27
77
|
}
|
28
78
|
end
|
@@ -57,7 +107,7 @@ module OracleSqlParser::Grammar
|
|
57
107
|
|
58
108
|
rule select_sources
|
59
109
|
join_clause /
|
60
|
-
'(' space? join_clause space? ')' /
|
110
|
+
'(' space? join_clause:join_clause space? ')' /
|
61
111
|
table_reference {
|
62
112
|
def ast
|
63
113
|
if respond_to? :join_clause
|
@@ -71,14 +121,16 @@ module OracleSqlParser::Grammar
|
|
71
121
|
|
72
122
|
rule join_clause
|
73
123
|
table_reference space
|
74
|
-
(
|
124
|
+
join:(
|
75
125
|
outer_join_clause /
|
76
|
-
inner_cross_join_clause
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
126
|
+
inner_cross_join_clause
|
127
|
+
) {
|
128
|
+
def ast
|
129
|
+
result = join.ast
|
130
|
+
result.table1 = table_reference.ast
|
131
|
+
result
|
132
|
+
end
|
133
|
+
}
|
82
134
|
end
|
83
135
|
|
84
136
|
rule inner_cross_join_clause
|
@@ -91,50 +143,119 @@ module OracleSqlParser::Grammar
|
|
91
143
|
end
|
92
144
|
|
93
145
|
rule inner_join_clause
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
146
|
+
inner_join space? table_reference space? on_or_using_clause {
|
147
|
+
def ast
|
148
|
+
OracleSqlParser::Ast::InnerJoinClause[
|
149
|
+
:inner => inner_join.inner_keyword.ast,
|
150
|
+
:join => inner_join.try(:join_keyword).ast,
|
151
|
+
:table2 => table_reference.ast,
|
152
|
+
:on_or_using_clause => on_or_using_clause.ast
|
153
|
+
]
|
154
|
+
end
|
155
|
+
}
|
156
|
+
end
|
157
|
+
|
158
|
+
rule inner_join
|
159
|
+
inner_keyword space? join_keyword
|
160
|
+
end
|
161
|
+
|
162
|
+
rule on_or_using_clause
|
163
|
+
on_clause /
|
164
|
+
using_clause {
|
99
165
|
def ast
|
100
|
-
|
166
|
+
super
|
167
|
+
end
|
168
|
+
}
|
169
|
+
end
|
170
|
+
|
171
|
+
rule on_clause
|
172
|
+
on_keyword space? condition {
|
173
|
+
def ast
|
174
|
+
OracleSqlParser::Ast::OnClause[
|
175
|
+
:on => on_keyword.ast,
|
176
|
+
:condition => condition.ast
|
177
|
+
]
|
178
|
+
end
|
179
|
+
}
|
180
|
+
end
|
181
|
+
|
182
|
+
rule using_clause
|
183
|
+
using_keyword space? '(' space? column_list space? ')' {
|
184
|
+
def ast
|
185
|
+
OracleSqlParser::Ast::UsingClause[
|
186
|
+
:using => using_keyword.ast,
|
187
|
+
:column_list => column_list.ast
|
188
|
+
]
|
101
189
|
end
|
102
190
|
}
|
103
191
|
end
|
104
192
|
|
105
193
|
rule cross_join_clause
|
106
|
-
|
107
|
-
cross_keyword /
|
108
|
-
natural_keyword (space inner_keyword)?
|
109
|
-
) space join_keyword space table_reference {
|
194
|
+
cross_natural_join space table_reference {
|
110
195
|
def ast
|
111
|
-
|
196
|
+
OracleSqlParser::Ast::CrossNaturalJoinClause[
|
197
|
+
:cross => cross_natural_join.cross_keyword.ast,
|
198
|
+
:natural => cross_natural_join.natural_keyword.ast,
|
199
|
+
:inner => cross_natural_join.inner_keyword.ast,
|
200
|
+
:join => cross_natural_join.try(:join_keyword).ast,
|
201
|
+
:table2 => table_reference.ast
|
202
|
+
]
|
203
|
+
end
|
204
|
+
}
|
205
|
+
end
|
206
|
+
|
207
|
+
rule cross_natural_join
|
208
|
+
(
|
209
|
+
cross_keyword:cross_keyword /
|
210
|
+
natural_keyword:natural_keyword inner:(space inner_keyword)?
|
211
|
+
) space join_keyword {
|
212
|
+
|
213
|
+
def cross_keyword
|
214
|
+
elements.first.try(:cross_keyword)
|
215
|
+
end
|
216
|
+
|
217
|
+
def natural_keyword
|
218
|
+
elements.first.try(:natural_keyword)
|
219
|
+
end
|
220
|
+
|
221
|
+
def inner_keyword
|
222
|
+
elements.first.try(:inner).try(:inner_keyword)
|
112
223
|
end
|
113
224
|
}
|
114
225
|
end
|
115
226
|
|
116
227
|
rule column_list
|
117
|
-
column_name (space? ',' space? column_name)* {
|
228
|
+
column_name more:(space? ',' space? column_name)* {
|
118
229
|
def ast
|
119
|
-
|
230
|
+
OracleSqlParser::Ast::Array[
|
231
|
+
column_name.ast,
|
232
|
+
*more_column_names.map(&:ast)
|
233
|
+
]
|
234
|
+
end
|
235
|
+
|
236
|
+
def more_column_names
|
237
|
+
more.elements.map(&:column_name)
|
120
238
|
end
|
121
239
|
}
|
122
240
|
end
|
123
241
|
|
124
242
|
rule outer_join_clause
|
125
243
|
query_partition_clause?
|
126
|
-
(
|
127
|
-
outer_join_type space? join_keyword
|
128
|
-
natural_keyword space? outer_join_type? space? join_keyword
|
244
|
+
join_type:(
|
245
|
+
natural_keyword:natural_keyword? space? outer_join_type:outer_join_type? space? join_keyword
|
129
246
|
) space
|
130
247
|
table_reference space
|
131
248
|
(query_partition_clause space)?
|
132
|
-
|
133
|
-
on_keyword space? condition /
|
134
|
-
using_keyword space '(' space? column_list space? ')'
|
135
|
-
) {
|
249
|
+
on_or_using_clause {
|
136
250
|
def ast
|
137
|
-
|
251
|
+
OracleSqlParser::Ast::OuterJoinClause[
|
252
|
+
:natural => join_type.try(:natural_keyword).ast,
|
253
|
+
:join_type => join_type.outer_join_type.try(:type).ast,
|
254
|
+
:outer => join_type.outer_join_type.try(:outer).ast,
|
255
|
+
:join => join_type.join_keyword.ast,
|
256
|
+
:table2 => table_reference.ast,
|
257
|
+
:on_or_using_clause => on_or_using_clause.ast
|
258
|
+
]
|
138
259
|
end
|
139
260
|
}
|
140
261
|
end
|
@@ -142,19 +263,19 @@ module OracleSqlParser::Grammar
|
|
142
263
|
rule query_partition_clause
|
143
264
|
'query_partition_clause' {
|
144
265
|
def ast
|
145
|
-
'query_partition_clause'
|
266
|
+
'query_partition_clause' # do not supported
|
146
267
|
end
|
147
268
|
}
|
148
269
|
end
|
149
270
|
|
150
271
|
rule outer_join_type
|
151
|
-
(
|
272
|
+
type:(
|
152
273
|
full_keyword /
|
153
274
|
left_keyword /
|
154
275
|
right_keyword
|
155
|
-
) (space outer_keyword)? {
|
156
|
-
def
|
157
|
-
|
276
|
+
) o:(space outer_keyword)? {
|
277
|
+
def outer
|
278
|
+
o.try(:outer_keyword)
|
158
279
|
end
|
159
280
|
}
|
160
281
|
end
|
@@ -164,7 +285,7 @@ module OracleSqlParser::Grammar
|
|
164
285
|
update_keyword space?
|
165
286
|
of:(of_keyword space for_update_clause_columns space?)?
|
166
287
|
wait:(
|
167
|
-
w:wait_keyword space? time:integer /
|
288
|
+
w:wait_keyword space? time:integer /
|
168
289
|
w:nowait_keyword
|
169
290
|
)? {
|
170
291
|
def ast
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oracle-sql-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Junichiro Kasuya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,25 +100,36 @@ files:
|
|
100
100
|
- lib/oracle-sql-parser/ast/base.rb
|
101
101
|
- lib/oracle-sql-parser/ast/between_condition.rb
|
102
102
|
- lib/oracle-sql-parser/ast/compound_condition.rb
|
103
|
+
- lib/oracle-sql-parser/ast/cross_natural_join_clause.rb
|
103
104
|
- lib/oracle-sql-parser/ast/current_of.rb
|
104
105
|
- lib/oracle-sql-parser/ast/delete_statement.rb
|
105
106
|
- lib/oracle-sql-parser/ast/delete_target.rb
|
106
107
|
- lib/oracle-sql-parser/ast/exists_condition.rb
|
108
|
+
- lib/oracle-sql-parser/ast/floating_point_condition.rb
|
107
109
|
- lib/oracle-sql-parser/ast/for_update_clause.rb
|
108
110
|
- lib/oracle-sql-parser/ast/function_expression.rb
|
109
111
|
- lib/oracle-sql-parser/ast/group_by_clause.rb
|
110
112
|
- lib/oracle-sql-parser/ast/hash.rb
|
111
113
|
- lib/oracle-sql-parser/ast/identifier.rb
|
112
114
|
- lib/oracle-sql-parser/ast/in_condition.rb
|
115
|
+
- lib/oracle-sql-parser/ast/inner_cross_join_clause.rb
|
116
|
+
- lib/oracle-sql-parser/ast/inner_join_clause.rb
|
113
117
|
- lib/oracle-sql-parser/ast/insert_statement.rb
|
114
118
|
- lib/oracle-sql-parser/ast/insert_values_clause.rb
|
119
|
+
- lib/oracle-sql-parser/ast/is_a_set_condition.rb
|
120
|
+
- lib/oracle-sql-parser/ast/is_empty_condition.rb
|
121
|
+
- lib/oracle-sql-parser/ast/is_of_type_condition.rb
|
115
122
|
- lib/oracle-sql-parser/ast/keyword.rb
|
116
123
|
- lib/oracle-sql-parser/ast/like_condition.rb
|
117
124
|
- lib/oracle-sql-parser/ast/logical_condition.rb
|
125
|
+
- lib/oracle-sql-parser/ast/member_condition.rb
|
118
126
|
- lib/oracle-sql-parser/ast/null_condition.rb
|
119
127
|
- lib/oracle-sql-parser/ast/number_literal.rb
|
128
|
+
- lib/oracle-sql-parser/ast/on_clause.rb
|
129
|
+
- lib/oracle-sql-parser/ast/only_and_type.rb
|
120
130
|
- lib/oracle-sql-parser/ast/order_by_clause.rb
|
121
131
|
- lib/oracle-sql-parser/ast/order_by_clause_item.rb
|
132
|
+
- lib/oracle-sql-parser/ast/outer_join_clause.rb
|
122
133
|
- lib/oracle-sql-parser/ast/query_block.rb
|
123
134
|
- lib/oracle-sql-parser/ast/regexp_condition.rb
|
124
135
|
- lib/oracle-sql-parser/ast/rollup_cube_clause.rb
|
@@ -126,12 +137,14 @@ files:
|
|
126
137
|
- lib/oracle-sql-parser/ast/select_statement.rb
|
127
138
|
- lib/oracle-sql-parser/ast/simple_case_expression.rb
|
128
139
|
- lib/oracle-sql-parser/ast/simple_comparision_condition.rb
|
140
|
+
- lib/oracle-sql-parser/ast/submultiset_condition.rb
|
129
141
|
- lib/oracle-sql-parser/ast/subquery.rb
|
130
142
|
- lib/oracle-sql-parser/ast/table_reference.rb
|
131
143
|
- lib/oracle-sql-parser/ast/text_literal.rb
|
132
144
|
- lib/oracle-sql-parser/ast/update_set_clause.rb
|
133
145
|
- lib/oracle-sql-parser/ast/update_set_column.rb
|
134
146
|
- lib/oracle-sql-parser/ast/update_statement.rb
|
147
|
+
- lib/oracle-sql-parser/ast/using_clause.rb
|
135
148
|
- lib/oracle-sql-parser/ast/variable.rb
|
136
149
|
- lib/oracle-sql-parser/ast/where_clause.rb
|
137
150
|
- lib/oracle-sql-parser/grammar.rb
|