oracle-sql-parser 1.0.0 → 1.1.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/CHANGELOG.md +213 -0
- data/LICENSE.txt +21 -0
- data/README.md +66 -3
- data/Rakefile +62 -10
- data/lib/oracle-sql-parser/grammar/condition/between.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/comparison.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/compound.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/exists.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/floating_point.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/in.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/is_of_type.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/multiset.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/null.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/pattern_matching.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition.rb +5 -3
- data/lib/oracle-sql-parser/grammar/delete.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/case.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/compound.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/cursor.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/datetime.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/function.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/interval.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/simple.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression.rb +5 -3
- data/lib/oracle-sql-parser/grammar/grammar.rb +5 -3
- data/lib/oracle-sql-parser/grammar/insert.rb +5 -3
- data/lib/oracle-sql-parser/grammar/reserved_word.rb +6 -4
- data/lib/oracle-sql-parser/grammar/reserved_word.treetop +1150 -0
- data/lib/oracle-sql-parser/grammar/reserved_word_generator.rb +1 -1
- data/lib/oracle-sql-parser/grammar/select/for_update.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/group.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/join.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/order.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/query_block.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/row_limit.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/union.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select.rb +5 -3
- data/lib/oracle-sql-parser/grammar/update.rb +5 -3
- data/lib/oracle-sql-parser/version.rb +1 -1
- data/oracle-sql-parser.gemspec +14 -11
- metadata +35 -41
- data/.gitignore +0 -24
- data/Gemfile +0 -4
- data/HISTORY.md +0 -77
- data/docker/oracle/Dockerfile +0 -3
- data/docker/test/Dockerfile +0 -21
- data/docker-compose.yml +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 799c6ff0310cf192261588ddf5ba07eb0aac1b5034b369b8dbbdf15d7decd9aa
|
|
4
|
+
data.tar.gz: b67a6a2237d6e7651ee4697e88dd2f4f6fd284ce840e25cdb186e15f9fff28f9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e528a35215101f8475613ac2fdafa5408db2d91f58c9b01caa06a03e7556d13f3eb3752ec7ad2eedae3ea52e9e0b558c24d68ed6c341ac03de5f3fbc0663f4f
|
|
7
|
+
data.tar.gz: 06b56b949569df4b737af0edb00b29ab71daad9ef14711775c3ff09a9750f4367ac1b9bc2ddf2e1f169c2743de3cb853ca0dea1073df5faa43de8c2b910c8972
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
> This file covers releases up to v1.0.0 and is no longer updated. Release
|
|
4
|
+
> notes for later versions live on
|
|
5
|
+
> [GitHub Releases](https://github.com/jksy/sql_parser/releases).
|
|
6
|
+
|
|
7
|
+
## [v1.0.0](https://github.com/jksy/sql_parser/tree/v1.0.0) (2020-02-28)
|
|
8
|
+
|
|
9
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.9.2...v1.0.0)
|
|
10
|
+
|
|
11
|
+
**Merged pull requests:**
|
|
12
|
+
|
|
13
|
+
- version 1.0.0 [\#22](https://github.com/jksy/sql_parser/pull/22) ([jksy](https://github.com/jksy))
|
|
14
|
+
- Feature/support rails5 [\#21](https://github.com/jksy/sql_parser/pull/21) ([jksy](https://github.com/jksy))
|
|
15
|
+
- v0.9.2 [\#20](https://github.com/jksy/sql_parser/pull/20) ([jksy](https://github.com/jksy))
|
|
16
|
+
|
|
17
|
+
## [v0.9.2](https://github.com/jksy/sql_parser/tree/v0.9.2) (2017-12-28)
|
|
18
|
+
|
|
19
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.9.1...v0.9.2)
|
|
20
|
+
|
|
21
|
+
**Merged pull requests:**
|
|
22
|
+
|
|
23
|
+
- fix method not found "keys" on hash [\#19](https://github.com/jksy/sql_parser/pull/19) ([jksy](https://github.com/jksy))
|
|
24
|
+
- Feature/update ruby versions [\#18](https://github.com/jksy/sql_parser/pull/18) ([jksy](https://github.com/jksy))
|
|
25
|
+
|
|
26
|
+
## [v0.9.1](https://github.com/jksy/sql_parser/tree/v0.9.1) (2017-09-18)
|
|
27
|
+
|
|
28
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.9.0...v0.9.1)
|
|
29
|
+
|
|
30
|
+
**Closed issues:**
|
|
31
|
+
|
|
32
|
+
- Three or more ANDs in WHERE clause fails parsing [\#16](https://github.com/jksy/sql_parser/issues/16)
|
|
33
|
+
|
|
34
|
+
**Merged pull requests:**
|
|
35
|
+
|
|
36
|
+
- fix https://github.com/jksy/sql\_parser/issues/16 [\#17](https://github.com/jksy/sql_parser/pull/17) ([jksy](https://github.com/jksy))
|
|
37
|
+
- ruby 2.4.1 [\#15](https://github.com/jksy/sql_parser/pull/15) ([jksy](https://github.com/jksy))
|
|
38
|
+
|
|
39
|
+
## [v0.9.0](https://github.com/jksy/sql_parser/tree/v0.9.0) (2016-09-03)
|
|
40
|
+
|
|
41
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.8.1...v0.9.0)
|
|
42
|
+
|
|
43
|
+
**Closed issues:**
|
|
44
|
+
|
|
45
|
+
- Parser fails when parsing table aliases. [\#8](https://github.com/jksy/sql_parser/issues/8)
|
|
46
|
+
|
|
47
|
+
**Merged pull requests:**
|
|
48
|
+
|
|
49
|
+
- release v0.9.0 [\#14](https://github.com/jksy/sql_parser/pull/14) ([jksy](https://github.com/jksy))
|
|
50
|
+
- Feature/expression [\#13](https://github.com/jksy/sql_parser/pull/13) ([jksy](https://github.com/jksy))
|
|
51
|
+
|
|
52
|
+
## [v0.8.1](https://github.com/jksy/sql_parser/tree/v0.8.1) (2016-08-14)
|
|
53
|
+
|
|
54
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.8.0...v0.8.1)
|
|
55
|
+
|
|
56
|
+
## [v0.8.0](https://github.com/jksy/sql_parser/tree/v0.8.0) (2016-08-14)
|
|
57
|
+
|
|
58
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.7.0...v0.8.0)
|
|
59
|
+
|
|
60
|
+
**Merged pull requests:**
|
|
61
|
+
|
|
62
|
+
- Feature/compound expression [\#11](https://github.com/jksy/sql_parser/pull/11) ([jksy](https://github.com/jksy))
|
|
63
|
+
- Feature/subqueries [\#10](https://github.com/jksy/sql_parser/pull/10) ([jksy](https://github.com/jksy))
|
|
64
|
+
|
|
65
|
+
## [v0.7.0](https://github.com/jksy/sql_parser/tree/v0.7.0) (2016-07-02)
|
|
66
|
+
|
|
67
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.6.0...v0.7.0)
|
|
68
|
+
|
|
69
|
+
**Merged pull requests:**
|
|
70
|
+
|
|
71
|
+
- added table alias syntax [\#9](https://github.com/jksy/sql_parser/pull/9) ([jksy](https://github.com/jksy))
|
|
72
|
+
|
|
73
|
+
## [v0.6.0](https://github.com/jksy/sql_parser/tree/v0.6.0) (2016-01-13)
|
|
74
|
+
|
|
75
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.5.1...v0.6.0)
|
|
76
|
+
|
|
77
|
+
## [v0.5.1](https://github.com/jksy/sql_parser/tree/v0.5.1) (2016-01-02)
|
|
78
|
+
|
|
79
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.5.0...v0.5.1)
|
|
80
|
+
|
|
81
|
+
**Merged pull requests:**
|
|
82
|
+
|
|
83
|
+
- Support rails query [\#7](https://github.com/jksy/sql_parser/pull/7) ([jksy](https://github.com/jksy))
|
|
84
|
+
- Fix spell [\#6](https://github.com/jksy/sql_parser/pull/6) ([jksy](https://github.com/jksy))
|
|
85
|
+
- added Travis-CI [\#5](https://github.com/jksy/sql_parser/pull/5) ([jksy](https://github.com/jksy))
|
|
86
|
+
- refactor gemspec [\#4](https://github.com/jksy/sql_parser/pull/4) ([jksy](https://github.com/jksy))
|
|
87
|
+
- added history.md [\#3](https://github.com/jksy/sql_parser/pull/3) ([jksy](https://github.com/jksy))
|
|
88
|
+
|
|
89
|
+
## [v0.5.0](https://github.com/jksy/sql_parser/tree/v0.5.0) (2015-12-28)
|
|
90
|
+
|
|
91
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.4.0...v0.5.0)
|
|
92
|
+
|
|
93
|
+
**Merged pull requests:**
|
|
94
|
+
|
|
95
|
+
- added NumberLiteral\#to\_cecimal, TextLiteral\#to\_s [\#2](https://github.com/jksy/sql_parser/pull/2) ([jksy](https://github.com/jksy))
|
|
96
|
+
|
|
97
|
+
## [v0.4.0](https://github.com/jksy/sql_parser/tree/v0.4.0) (2015-09-01)
|
|
98
|
+
|
|
99
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.3.1...v0.4.0)
|
|
100
|
+
|
|
101
|
+
## [v0.3.1](https://github.com/jksy/sql_parser/tree/v0.3.1) (2015-08-27)
|
|
102
|
+
|
|
103
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.3.0...v0.3.1)
|
|
104
|
+
|
|
105
|
+
## [v0.3.0](https://github.com/jksy/sql_parser/tree/v0.3.0) (2015-08-27)
|
|
106
|
+
|
|
107
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.2.0...v0.3.0)
|
|
108
|
+
|
|
109
|
+
## [v0.2.0](https://github.com/jksy/sql_parser/tree/v0.2.0) (2015-08-24)
|
|
110
|
+
|
|
111
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.1.1...v0.2.0)
|
|
112
|
+
|
|
113
|
+
## [v0.1.1](https://github.com/jksy/sql_parser/tree/v0.1.1) (2015-08-12)
|
|
114
|
+
|
|
115
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/v0.1.0...v0.1.1)
|
|
116
|
+
|
|
117
|
+
## [v0.1.0](https://github.com/jksy/sql_parser/tree/v0.1.0) (2015-08-03)
|
|
118
|
+
|
|
119
|
+
[Full Changelog](https://github.com/jksy/sql_parser/compare/131eba24eb79a0617c59210535da5d00dd6ee012...v0.1.0)
|
|
120
|
+
|
|
121
|
+
**Merged pull requests:**
|
|
122
|
+
|
|
123
|
+
- racc -\> treetop [\#1](https://github.com/jksy/sql_parser/pull/1) ([jksy](https://github.com/jksy))
|
|
124
|
+
|
|
125
|
+
## Release notes (formerly HISTORY.md)
|
|
126
|
+
|
|
127
|
+
### 1.0.0
|
|
128
|
+
* Pass test on Rails 5.1.7
|
|
129
|
+
* Drop support version before 2.3.8
|
|
130
|
+
* Added grammer for "SELECT * FROM {table_name} FETCH FIRST {number} ROWS ONLY".
|
|
131
|
+
* The grammer is used by Model.limit(10) with Oracle 18g through ActiveRecord
|
|
132
|
+
* Remove code for Ruby version 1.9.x
|
|
133
|
+
|
|
134
|
+
### 0.9.2
|
|
135
|
+
* bug fix method not found "keys" on hash
|
|
136
|
+
|
|
137
|
+
### 0.9.1
|
|
138
|
+
* Syntax
|
|
139
|
+
* Three or more ANDs in WHERE clause fails parsing https://github.com/jksy/sql_parser/issues/16
|
|
140
|
+
|
|
141
|
+
### 0.9.0
|
|
142
|
+
* Syntax
|
|
143
|
+
* added cursor expression
|
|
144
|
+
* added datetime expression
|
|
145
|
+
* added interval expression
|
|
146
|
+
|
|
147
|
+
### 0.8.1
|
|
148
|
+
* Fix README.md
|
|
149
|
+
|
|
150
|
+
### 0.8.0
|
|
151
|
+
* Syntax
|
|
152
|
+
* subquery https://github.com/jksy/sql_parser/issues/8
|
|
153
|
+
* "select col1 from table1 union select col2 from table2 union select col3 from table3"
|
|
154
|
+
* "select col1 from table1 union (select col2 from table2)"
|
|
155
|
+
* compound expression https://github.com/jksy/sql_parser/issues/8
|
|
156
|
+
* "select 1-1 from table1"
|
|
157
|
+
* Broken changes
|
|
158
|
+
* select_list.
|
|
159
|
+
Ast::Array[ Ast::Ident[..], Ast::Ident[..]] Ast::Array[ Ast::SelectColumn[:expr => Ast::Ident[..]],...]
|
|
160
|
+
|
|
161
|
+
### 0.7.0
|
|
162
|
+
* Syntax
|
|
163
|
+
* table alias, like "select a.* from table1 a". https://github.com/jksy/sql_parser/issues/8
|
|
164
|
+
|
|
165
|
+
### 0.6.0
|
|
166
|
+
* Enchancement
|
|
167
|
+
* added travis-ci
|
|
168
|
+
* added oracle enhanced adapter query(select, includes, joins, where)
|
|
169
|
+
* Syntax
|
|
170
|
+
* added syntax for column_alias
|
|
171
|
+
|
|
172
|
+
### 0.5.1
|
|
173
|
+
* Bug fix
|
|
174
|
+
* fix spell. to_pameternized is deprecated and will be removed. use to_parameterized
|
|
175
|
+
|
|
176
|
+
### 0.5.0
|
|
177
|
+
* Enchancement
|
|
178
|
+
* added NumberLiteral#to_cecimal, TextLiteral#to_s
|
|
179
|
+
|
|
180
|
+
### 0.4.0
|
|
181
|
+
* Bugfix
|
|
182
|
+
* rename ParameternizedQuery#query -> ParameternizedQuery#to_sql
|
|
183
|
+
* Syntax
|
|
184
|
+
* union [all]
|
|
185
|
+
* intersect
|
|
186
|
+
* minus
|
|
187
|
+
* [inner|outer] join
|
|
188
|
+
* conditions
|
|
189
|
+
* floating point condition
|
|
190
|
+
* multiset condition
|
|
191
|
+
* is_of_type condition
|
|
192
|
+
|
|
193
|
+
### 0.3.0
|
|
194
|
+
* Enchancement
|
|
195
|
+
* added to_parameternized method
|
|
196
|
+
|
|
197
|
+
* Bug fix
|
|
198
|
+
* to_sql when select multiple column query parsed
|
|
199
|
+
|
|
200
|
+
### 0.2.0
|
|
201
|
+
* Bug fix
|
|
202
|
+
* Identifier[:value => ..] -> Identifier[:name => ..] when use sequence.nextval
|
|
203
|
+
* refactor test cases
|
|
204
|
+
|
|
205
|
+
### 0.1.1
|
|
206
|
+
* Syntax
|
|
207
|
+
* support double-quoted identifer
|
|
208
|
+
|
|
209
|
+
### 0.1.0
|
|
210
|
+
* Initial version
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Junichiro Kasuya
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
# OracleSqlParser
|
|
2
2
|
|
|
3
|
-
[](https://github.com/jksy/sql_parser/actions/workflows/ci.yml)
|
|
4
|
+
[](https://codecov.io/gh/jksy/sql_parser)
|
|
4
5
|
|
|
5
6
|
SQL Parser for Oracle
|
|
6
7
|
|
|
8
|
+
## Requirements
|
|
9
|
+
|
|
10
|
+
Ruby 3.2 or later (CI runs on 3.2, 3.3, 3.4 and 4.0). The gem itself does not
|
|
11
|
+
need an Oracle client; only the connection tests described under
|
|
12
|
+
[Development](#development) do.
|
|
13
|
+
|
|
7
14
|
## Installation
|
|
8
15
|
|
|
9
16
|
Add this line to your application's Gemfile:
|
|
@@ -78,10 +85,66 @@ p.params.inspect
|
|
|
78
85
|
=> {"a0"=>#<OracleSqlParser::Ast::NumberLiteral {:value=>"1"}>}
|
|
79
86
|
</pre>
|
|
80
87
|
|
|
88
|
+
## Development
|
|
89
|
+
|
|
90
|
+
$ bundle install
|
|
91
|
+
$ bundle exec rake test:unit # parser tests, no Oracle required
|
|
92
|
+
|
|
93
|
+
The parsers under `lib/oracle-sql-parser/grammar/` are generated from the
|
|
94
|
+
`.treetop` grammars next to them and the generated `.rb` files are committed.
|
|
95
|
+
After editing a grammar (or `reserved_word_generator.rb`), regenerate and
|
|
96
|
+
commit the result; CI fails if the committed parsers are out of date:
|
|
97
|
+
|
|
98
|
+
$ bundle exec rake gen_force # compile **/*.treetop
|
|
99
|
+
|
|
100
|
+
The tests under `test/oracle_enhanced-adapter` run real queries through
|
|
101
|
+
[activerecord-oracle_enhanced-adapter](https://github.com/rsim/oracle-enhanced)
|
|
102
|
+
and need Oracle Instant Client plus a reachable Oracle database. The easiest
|
|
103
|
+
way to get both is the dev container in `.devcontainer/`, which starts
|
|
104
|
+
[Oracle Database Free](https://github.com/gvenzl/oci-oracle-free) next to a
|
|
105
|
+
Ruby container that has Instant Client installed. Open the repository in the
|
|
106
|
+
container (VS Code "Reopen in Container", or the
|
|
107
|
+
[devcontainer CLI](https://github.com/devcontainers/cli)) and run the tests:
|
|
108
|
+
|
|
109
|
+
$ devcontainer up --workspace-folder .
|
|
110
|
+
$ devcontainer exec --workspace-folder . bundle exec rake test # test:unit and test:adapter
|
|
111
|
+
|
|
112
|
+
The Oracle gems are managed with [Appraisal](https://github.com/thoughtbot/appraisal)
|
|
113
|
+
so that a plain `bundle install` works without Oracle; `rake test:adapter`
|
|
114
|
+
switches to `gemfiles/adapter_6.gemfile` by itself when the current bundle does
|
|
115
|
+
not have them. There is one appraisal per ActiveRecord version the tests are
|
|
116
|
+
run against (6.1, 7.2 and 8.1, see `Appraisals`); to run the tests with all of
|
|
117
|
+
them:
|
|
118
|
+
|
|
119
|
+
$ bundle exec appraisal rake test:adapter:run
|
|
120
|
+
|
|
121
|
+
To run against another Oracle database instead, install the appraisal gems and
|
|
122
|
+
point the tests at it:
|
|
123
|
+
|
|
124
|
+
$ bundle exec appraisal install
|
|
125
|
+
$ export ORACLE_USERNAME=... ORACLE_PASSWORD=... ORACLE_HOST=localhost ORACLE_PORT=1521 ORACLE_SID=FREEPDB1
|
|
126
|
+
$ bundle exec rake test:adapter
|
|
127
|
+
|
|
128
|
+
Connection settings can also be put in `test/oracle_enhanced-adapter/connection_params.yml`
|
|
129
|
+
(ignored by git).
|
|
130
|
+
|
|
131
|
+
## Release
|
|
132
|
+
|
|
133
|
+
Release notes live on [GitHub Releases](https://github.com/jksy/sql_parser/releases)
|
|
134
|
+
and are generated from the merged pull requests, grouped by label
|
|
135
|
+
(`.github/release.yml`). `CHANGELOG.md` is kept for history only.
|
|
136
|
+
|
|
137
|
+
1. Open a pull request that updates `lib/oracle-sql-parser/version.rb`, label
|
|
138
|
+
it `release` (so it is left out of the notes) and merge it.
|
|
139
|
+
2. On `master`, run `bundle exec rake release`, which creates the `v<version>`
|
|
140
|
+
tag, pushes it and publishes the gem to [rubygems.org](https://rubygems.org).
|
|
141
|
+
3. On GitHub, draft a release for the tag, click "Generate release notes" and
|
|
142
|
+
publish it.
|
|
143
|
+
|
|
81
144
|
## Contributing
|
|
82
145
|
|
|
83
146
|
Bug reports and pull requests are welcome on GitHub at https://github.com/jksy/sql_parser.
|
|
84
147
|
|
|
85
|
-
##
|
|
148
|
+
## License
|
|
86
149
|
|
|
87
|
-
|
|
150
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
|
@@ -3,6 +3,9 @@ require 'rake'
|
|
|
3
3
|
require 'rake/testtask'
|
|
4
4
|
|
|
5
5
|
GRAMMAR_FILES = FileList['lib/oracle-sql-parser/grammar/**/*.treetop']
|
|
6
|
+
# The Oracle gems live in the appraisal gemfiles (see Appraisals); test:adapter
|
|
7
|
+
# re-runs itself under this one when the current bundle does not have them.
|
|
8
|
+
ADAPTER_GEMFILE = 'gemfiles/adapter_6.gemfile'.freeze
|
|
6
9
|
|
|
7
10
|
desc "generate parser files"
|
|
8
11
|
task :gen do
|
|
@@ -18,20 +21,69 @@ desc "clean files"
|
|
|
18
21
|
task :clean do
|
|
19
22
|
GRAMMAR_FILES.each do |f|
|
|
20
23
|
file = "#{f.gsub(/\.treetop$/,'')}.rb"
|
|
21
|
-
File.unlink file if File.
|
|
24
|
+
File.unlink file if File.exist? file
|
|
22
25
|
end
|
|
23
26
|
end
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
namespace :test do
|
|
29
|
+
Rake::TestTask.new(:unit) do |t|
|
|
30
|
+
t.description = "run parser tests (no Oracle required)"
|
|
31
|
+
t.libs << "test"
|
|
32
|
+
t.test_files = FileList[
|
|
33
|
+
'test/grammar/*_test.rb',
|
|
34
|
+
'test/ast/*_test.rb'
|
|
35
|
+
]
|
|
36
|
+
t.verbose = true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
namespace :adapter do
|
|
40
|
+
Rake::TestTask.new(:run) do |t|
|
|
41
|
+
t.description = "run Oracle connection tests in the current bundle"
|
|
42
|
+
t.libs << "test"
|
|
43
|
+
t.test_files = FileList['test/oracle_enhanced-adapter/select_test.rb']
|
|
44
|
+
t.verbose = true
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
desc "run Oracle connection tests (needs an Oracle DB; uses #{ADAPTER_GEMFILE} unless the current bundle has the adapter)"
|
|
49
|
+
task :adapter do
|
|
50
|
+
if adapter_gems_available?
|
|
51
|
+
Rake::Task['test:adapter:run'].invoke
|
|
52
|
+
else
|
|
53
|
+
sh({ 'BUNDLE_GEMFILE' => ADAPTER_GEMFILE }, 'bundle', 'exec', 'rake', 'test:adapter:run')
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Name each SimpleCov run so results from test:unit and test:adapter merge.
|
|
59
|
+
task 'test:unit:coverage_name' do
|
|
60
|
+
ENV['SIMPLECOV_COMMAND_NAME'] = 'unit'
|
|
61
|
+
end
|
|
62
|
+
task 'test:adapter:coverage_name' do
|
|
63
|
+
ENV['SIMPLECOV_COMMAND_NAME'] = 'adapter'
|
|
33
64
|
end
|
|
65
|
+
task 'test:unit' => 'test:unit:coverage_name'
|
|
66
|
+
task 'test:adapter:run' => 'test:adapter:coverage_name'
|
|
34
67
|
|
|
68
|
+
desc "run all tests (test:unit and test:adapter)"
|
|
69
|
+
task :test => ['test:unit', 'test:adapter']
|
|
70
|
+
|
|
71
|
+
desc "run RuboCop"
|
|
72
|
+
task :rubocop do
|
|
73
|
+
sh "rubocop"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
desc "run what CI runs: RuboCop and the parser tests"
|
|
77
|
+
task :ci => [:rubocop, 'test:unit']
|
|
78
|
+
|
|
79
|
+
task :default => 'test:unit'
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def adapter_gems_available?
|
|
83
|
+
Bundler.load.specs.any? { |spec| spec.name == 'activerecord-oracle_enhanced-adapter' }
|
|
84
|
+
rescue Bundler::BundlerError
|
|
85
|
+
false
|
|
86
|
+
end
|
|
35
87
|
|
|
36
88
|
def generate_parser_files(force = false)
|
|
37
89
|
word_generator = "lib/oracle-sql-parser/grammar/reserved_word_generator.rb"
|
|
@@ -54,7 +106,7 @@ def tt(f, force = false)
|
|
|
54
106
|
end
|
|
55
107
|
|
|
56
108
|
def do_if_changed(src, output, force = false, &block)
|
|
57
|
-
force = true unless File.
|
|
109
|
+
force = true unless File.exist?(output)
|
|
58
110
|
if force || File::Stat.new(src).mtime >= File::Stat.new(output).mtime
|
|
59
111
|
yield
|
|
60
112
|
end
|
|
@@ -158,10 +158,12 @@ module OracleSqlParser::Grammar::Condition
|
|
|
158
158
|
r0
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
end
|
|
162
161
|
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
163
|
+
include Between
|
|
164
|
+
end
|
|
165
165
|
end
|
|
166
166
|
|
|
167
|
+
(remove_const(:BetweenParser) if const_defined?(:BetweenParser)) rescue nil; BetweenParser = Between::Parser
|
|
168
|
+
|
|
167
169
|
end
|
|
@@ -443,10 +443,12 @@ module OracleSqlParser::Grammar::Condition
|
|
|
443
443
|
r0
|
|
444
444
|
end
|
|
445
445
|
|
|
446
|
-
end
|
|
447
446
|
|
|
448
|
-
|
|
449
|
-
|
|
447
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
448
|
+
include Comparison
|
|
449
|
+
end
|
|
450
450
|
end
|
|
451
451
|
|
|
452
|
+
(remove_const(:ComparisonParser) if const_defined?(:ComparisonParser)) rescue nil; ComparisonParser = Comparison::Parser
|
|
453
|
+
|
|
452
454
|
end
|
|
@@ -70,10 +70,12 @@ module OracleSqlParser::Grammar::Condition
|
|
|
70
70
|
r0
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
end
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
75
|
+
include Compound
|
|
76
|
+
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
+
(remove_const(:CompoundParser) if const_defined?(:CompoundParser)) rescue nil; CompoundParser = Compound::Parser
|
|
80
|
+
|
|
79
81
|
end
|
|
@@ -107,10 +107,12 @@ module OracleSqlParser::Grammar::Condition
|
|
|
107
107
|
r0
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
end
|
|
111
110
|
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
112
|
+
include Exists
|
|
113
|
+
end
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
+
(remove_const(:ExistsParser) if const_defined?(:ExistsParser)) rescue nil; ExistsParser = Exists::Parser
|
|
117
|
+
|
|
116
118
|
end
|
|
@@ -124,10 +124,12 @@ module OracleSqlParser::Grammar::Condition
|
|
|
124
124
|
r0
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
-
end
|
|
128
127
|
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
129
|
+
include FloatingPoint
|
|
130
|
+
end
|
|
131
131
|
end
|
|
132
132
|
|
|
133
|
+
(remove_const(:FloatingPointParser) if const_defined?(:FloatingPointParser)) rescue nil; FloatingPointParser = FloatingPoint::Parser
|
|
134
|
+
|
|
133
135
|
end
|
|
@@ -179,10 +179,12 @@ module OracleSqlParser::Grammar::Condition
|
|
|
179
179
|
r0
|
|
180
180
|
end
|
|
181
181
|
|
|
182
|
-
end
|
|
183
182
|
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
184
|
+
include In
|
|
185
|
+
end
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
+
(remove_const(:InParser) if const_defined?(:InParser)) rescue nil; InParser = In::Parser
|
|
189
|
+
|
|
188
190
|
end
|
|
@@ -442,10 +442,12 @@ module OracleSqlParser::Grammar::Condition
|
|
|
442
442
|
r0
|
|
443
443
|
end
|
|
444
444
|
|
|
445
|
-
end
|
|
446
445
|
|
|
447
|
-
|
|
448
|
-
|
|
446
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
447
|
+
include IsOfType
|
|
448
|
+
end
|
|
449
449
|
end
|
|
450
450
|
|
|
451
|
+
(remove_const(:IsOfTypeParser) if const_defined?(:IsOfTypeParser)) rescue nil; IsOfTypeParser = IsOfType::Parser
|
|
452
|
+
|
|
451
453
|
end
|
|
@@ -556,11 +556,13 @@ module OracleSqlParser::Grammar::Condition
|
|
|
556
556
|
r0
|
|
557
557
|
end
|
|
558
558
|
|
|
559
|
-
end
|
|
560
559
|
|
|
561
|
-
|
|
562
|
-
|
|
560
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
561
|
+
include Multiset
|
|
562
|
+
end
|
|
563
563
|
end
|
|
564
564
|
|
|
565
|
+
(remove_const(:MultisetParser) if const_defined?(:MultisetParser)) rescue nil; MultisetParser = Multiset::Parser
|
|
566
|
+
|
|
565
567
|
end
|
|
566
568
|
|
|
@@ -123,10 +123,12 @@ module OracleSqlParser::Grammar::Condition
|
|
|
123
123
|
r0
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
-
end
|
|
127
126
|
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
128
|
+
include Null
|
|
129
|
+
end
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
+
(remove_const(:NullParser) if const_defined?(:NullParser)) rescue nil; NullParser = Null::Parser
|
|
133
|
+
|
|
132
134
|
end
|
|
@@ -373,10 +373,12 @@ module OracleSqlParser::Grammar::Condition
|
|
|
373
373
|
r0
|
|
374
374
|
end
|
|
375
375
|
|
|
376
|
-
end
|
|
377
376
|
|
|
378
|
-
|
|
379
|
-
|
|
377
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
378
|
+
include PatternMatching
|
|
379
|
+
end
|
|
380
380
|
end
|
|
381
381
|
|
|
382
|
+
(remove_const(:PatternMatchingParser) if const_defined?(:PatternMatchingParser)) rescue nil; PatternMatchingParser = PatternMatching::Parser
|
|
383
|
+
|
|
382
384
|
end
|
|
@@ -478,10 +478,12 @@ module OracleSqlParser::Grammar
|
|
|
478
478
|
r0
|
|
479
479
|
end
|
|
480
480
|
|
|
481
|
-
end
|
|
482
481
|
|
|
483
|
-
|
|
484
|
-
|
|
482
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
483
|
+
include Condition
|
|
484
|
+
end
|
|
485
485
|
end
|
|
486
486
|
|
|
487
|
+
(remove_const(:ConditionParser) if const_defined?(:ConditionParser)) rescue nil; ConditionParser = Condition::Parser
|
|
488
|
+
|
|
487
489
|
end
|
|
@@ -485,10 +485,12 @@ module OracleSqlParser::Grammar
|
|
|
485
485
|
r0
|
|
486
486
|
end
|
|
487
487
|
|
|
488
|
-
end
|
|
489
488
|
|
|
490
|
-
|
|
491
|
-
|
|
489
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
490
|
+
include Delete
|
|
491
|
+
end
|
|
492
492
|
end
|
|
493
493
|
|
|
494
|
+
(remove_const(:DeleteParser) if const_defined?(:DeleteParser)) rescue nil; DeleteParser = Delete::Parser
|
|
495
|
+
|
|
494
496
|
end
|
|
@@ -506,10 +506,12 @@ module OracleSqlParser::Grammar::Expression
|
|
|
506
506
|
r0
|
|
507
507
|
end
|
|
508
508
|
|
|
509
|
-
end
|
|
510
509
|
|
|
511
|
-
|
|
512
|
-
|
|
510
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
511
|
+
include Case
|
|
512
|
+
end
|
|
513
513
|
end
|
|
514
514
|
|
|
515
|
+
(remove_const(:CaseParser) if const_defined?(:CaseParser)) rescue nil; CaseParser = Case::Parser
|
|
516
|
+
|
|
515
517
|
end
|
|
@@ -322,10 +322,12 @@ module OracleSqlParser::Grammar::Expression
|
|
|
322
322
|
r0
|
|
323
323
|
end
|
|
324
324
|
|
|
325
|
-
end
|
|
326
325
|
|
|
327
|
-
|
|
328
|
-
|
|
326
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
327
|
+
include Compound
|
|
328
|
+
end
|
|
329
329
|
end
|
|
330
330
|
|
|
331
|
+
(remove_const(:CompoundParser) if const_defined?(:CompoundParser)) rescue nil; CompoundParser = Compound::Parser
|
|
332
|
+
|
|
331
333
|
end
|