twowaysql 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -2
- data/Manifest.txt +5 -0
- data/README.txt +2 -2
- data/issues/issue-1cee7e821865a216674832b0186bd92792680571.yaml +30 -0
- data/issues/issue-25efcfc383f3b0f6c0e2730ae7c2975bb2b3de26.yaml +1 -1
- data/issues/issue-39023ea09e17e2d64bcef03aa59cdfe38b78ad5b.yaml +9 -1
- data/issues/issue-5c973ef5bb074eacca0c6c84f7d27c4267773ea8.yaml +30 -0
- data/issues/issue-664986b219202ff1948cab717b56e7540f493561.yaml +22 -0
- data/issues/issue-897995fa10377eabdf597e8e7692f17087c76923.yaml +15 -2
- data/issues/issue-901f65630639507c8b05b466790e9f22256c6450.yaml +18 -0
- data/issues/issue-dca4b19aa13de59838b33e03252bf824670a2d12.yaml +30 -0
- data/issues/issue-f39b907d01d7fa93df8c7a9de2e1b5e27727ee0a.yaml +21 -5
- data/issues/issue-f64d73ed4f9854f1ded77e6496dbf59cfb3770a7.yaml +5 -1
- data/issues/project.yaml +28 -2
- data/lib/twowaysql/node.rb +13 -23
- data/lib/twowaysql/parser.rb +143 -115
- data/lib/twowaysql/parser.y +43 -29
- data/lib/twowaysql/version.rb +1 -1
- data/spec/large_sql_spec.rb +35 -1
- data/spec/spec_helper.rb +33 -0
- data/tasks/deployment.rake +1 -0
- data/tasks/ditz.rake +4 -7
- data/tasks/website.rake +1 -1
- metadata +7 -2
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
-
== 0.2.0 2008-09-
|
2
|
-
|
1
|
+
== 0.2.0 / 2008-09-05
|
3
2
|
* Initial release
|
3
|
+
* RubyForge settings
|
4
|
+
* rdoc for published classes and methods
|
5
|
+
|
6
|
+
== 0.2.1 / 2008-09-07
|
7
|
+
* bugfix: case insensitive match for SQL reserved words
|
8
|
+
* make Ruby1.9 ready
|
9
|
+
* integrate ditz html into site
|
10
|
+
* change idiom 'substitution' to 'interpolation'
|
11
|
+
* Handle Embedded variable comment at Scanner/Grammar level
|
data/Manifest.txt
CHANGED
@@ -5,11 +5,16 @@ README.txt
|
|
5
5
|
Rakefile
|
6
6
|
config/hoe.rb
|
7
7
|
config/requirements.rb
|
8
|
+
issues/issue-1cee7e821865a216674832b0186bd92792680571.yaml
|
8
9
|
issues/issue-25efcfc383f3b0f6c0e2730ae7c2975bb2b3de26.yaml
|
9
10
|
issues/issue-39023ea09e17e2d64bcef03aa59cdfe38b78ad5b.yaml
|
10
11
|
issues/issue-4bc308d55ae91f266e656162a4147d356de1166c.yaml
|
12
|
+
issues/issue-5c973ef5bb074eacca0c6c84f7d27c4267773ea8.yaml
|
13
|
+
issues/issue-664986b219202ff1948cab717b56e7540f493561.yaml
|
11
14
|
issues/issue-897995fa10377eabdf597e8e7692f17087c76923.yaml
|
15
|
+
issues/issue-901f65630639507c8b05b466790e9f22256c6450.yaml
|
12
16
|
issues/issue-bd38c1cdc965d73dd629a81db2de1bcdcf4b10b8.yaml
|
17
|
+
issues/issue-dca4b19aa13de59838b33e03252bf824670a2d12.yaml
|
13
18
|
issues/issue-f2b773020b54f839c03d899b38b5113c8fd991df.yaml
|
14
19
|
issues/issue-f39b907d01d7fa93df8c7a9de2e1b5e27727ee0a.yaml
|
15
20
|
issues/issue-f64d73ed4f9854f1ded77e6496dbf59cfb3770a7.yaml
|
data/README.txt
CHANGED
@@ -38,7 +38,7 @@ TwoWaySQL provides better separation of host language and SQL.
|
|
38
38
|
|
39
39
|
With TwoWaySQL, you can
|
40
40
|
* separate SQL (as file) from host language
|
41
|
-
* bind variables to SQL using
|
41
|
+
* bind variables to SQL using Interpolation comments
|
42
42
|
* modify SQL conditionally by using Directive comments
|
43
43
|
* run and preview TwoWaySQL-style SQL by tools like pgAdmin3, since the SQL is still valid SQL.
|
44
44
|
|
@@ -110,7 +110,7 @@ TwoWaySQL is not
|
|
110
110
|
|
111
111
|
== FEATURES/PROBLEMS:
|
112
112
|
|
113
|
-
*
|
113
|
+
* Interpolation comments
|
114
114
|
* Bind variable comment
|
115
115
|
* Embedded variable comment
|
116
116
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: make Ruby1.9 ready
|
3
|
+
desc: make sure to work under Ruby1.9
|
4
|
+
type: :feature
|
5
|
+
component: twowaysql
|
6
|
+
release: release_0_2_1
|
7
|
+
reporter: takuto <takuto.wada@gmail.com>
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
|
+
creation_time: 2008-09-05 14:32:11.017805 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 1cee7e821865a216674832b0186bd92792680571
|
14
|
+
log_events:
|
15
|
+
- - 2008-09-05 14:33:13.624689 Z
|
16
|
+
- takuto <takuto.wada@gmail.com>
|
17
|
+
- created
|
18
|
+
- ""
|
19
|
+
- - 2008-09-05 14:34:03.805045 Z
|
20
|
+
- takuto <takuto.wada@gmail.com>
|
21
|
+
- changed status from unstarted to in_progress
|
22
|
+
- ""
|
23
|
+
- - 2008-09-05 14:58:22.094256 Z
|
24
|
+
- takuto <takuto.wada@gmail.com>
|
25
|
+
- closed with disposition fixed
|
26
|
+
- done.
|
27
|
+
- - 2008-09-07 16:16:17.406228 Z
|
28
|
+
- takuto <takuto.wada@gmail.com>
|
29
|
+
- assigned to release release_0_2_1 from release_0_3
|
30
|
+
- ""
|
@@ -3,7 +3,7 @@ title: integrate ditz html into site
|
|
3
3
|
desc: Integrate ditz html output into site. Ditz site(http://ditz.rubyforge.org/ditz) may help.
|
4
4
|
type: :task
|
5
5
|
component: twowaysql
|
6
|
-
release:
|
6
|
+
release: release_0_2_1
|
7
7
|
reporter: takuto <takuto.wada@gmail.com>
|
8
8
|
status: :closed
|
9
9
|
disposition: :fixed
|
@@ -24,3 +24,11 @@ log_events:
|
|
24
24
|
- takuto <takuto.wada@gmail.com>
|
25
25
|
- closed with disposition fixed
|
26
26
|
- done.
|
27
|
+
- - 2008-09-07 16:12:29.395340 Z
|
28
|
+
- takuto <takuto.wada@gmail.com>
|
29
|
+
- assigned to release release_0_3 from unassigned
|
30
|
+
- ""
|
31
|
+
- - 2008-09-07 16:15:39.449630 Z
|
32
|
+
- takuto <takuto.wada@gmail.com>
|
33
|
+
- assigned to release release_0_2_1 from release_0_3
|
34
|
+
- ""
|
@@ -0,0 +1,30 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: case insensitive match for SQL reserved words
|
3
|
+
desc: case insensitive match for SQL reserved words
|
4
|
+
type: :bugfix
|
5
|
+
component: twowaysql
|
6
|
+
release: release_0_2_1
|
7
|
+
reporter: takuto <takuto.wada@gmail.com>
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
|
+
creation_time: 2008-09-06 08:22:09.096464 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 5c973ef5bb074eacca0c6c84f7d27c4267773ea8
|
14
|
+
log_events:
|
15
|
+
- - 2008-09-06 08:22:13.438780 Z
|
16
|
+
- takuto <takuto.wada@gmail.com>
|
17
|
+
- created
|
18
|
+
- ""
|
19
|
+
- - 2008-09-06 08:24:42.298213 Z
|
20
|
+
- takuto <takuto.wada@gmail.com>
|
21
|
+
- changed status from unstarted to in_progress
|
22
|
+
- ""
|
23
|
+
- - 2008-09-06 18:48:46.516332 Z
|
24
|
+
- takuto <takuto.wada@gmail.com>
|
25
|
+
- closed with disposition fixed
|
26
|
+
- ""
|
27
|
+
- - 2008-09-07 16:16:22.125681 Z
|
28
|
+
- takuto <takuto.wada@gmail.com>
|
29
|
+
- assigned to release release_0_2_1 from release_0_3
|
30
|
+
- ""
|
@@ -0,0 +1,22 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: line number support on parse error
|
3
|
+
desc: show line number of SQL when parse error has occurred.
|
4
|
+
type: :feature
|
5
|
+
component: twowaysql
|
6
|
+
release: release_0_3
|
7
|
+
reporter: takuto <takuto.wada@gmail.com>
|
8
|
+
status: :unstarted
|
9
|
+
disposition:
|
10
|
+
creation_time: 2008-09-06 07:38:16.872853 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 664986b219202ff1948cab717b56e7540f493561
|
14
|
+
log_events:
|
15
|
+
- - 2008-09-06 07:39:56.519949 Z
|
16
|
+
- takuto <takuto.wada@gmail.com>
|
17
|
+
- created
|
18
|
+
- work with multiline parsing?
|
19
|
+
- - 2008-09-07 14:11:28.508490 Z
|
20
|
+
- takuto <takuto.wada@gmail.com>
|
21
|
+
- assigned to release release_0_3 from unassigned
|
22
|
+
- assign to release_0_3
|
@@ -5,8 +5,8 @@ type: :task
|
|
5
5
|
component: twowaysql
|
6
6
|
release: 0.2 release
|
7
7
|
reporter: takuto <takuto.wada@gmail.com>
|
8
|
-
status: :
|
9
|
-
disposition:
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
10
|
creation_time: 2008-09-04 17:02:51.175082 Z
|
11
11
|
references: []
|
12
12
|
|
@@ -24,3 +24,16 @@ log_events:
|
|
24
24
|
- takuto <takuto.wada@gmail.com>
|
25
25
|
- changed status from unstarted to in_progress
|
26
26
|
- ""
|
27
|
+
- - 2008-09-05 08:06:48.196336 Z
|
28
|
+
- takuto <takuto.wada@gmail.com>
|
29
|
+
- closed with disposition fixed
|
30
|
+
- |-
|
31
|
+
version 0.2.0 deploy done(gem, website, rdoc).
|
32
|
+
these sites are very helpful when wrestling with rubyforge
|
33
|
+
http://fromnorth.blogspot.com/2008/06/rubygem.html
|
34
|
+
http://blog.bogojoker.com/category/rr/
|
35
|
+
short summary of workaround
|
36
|
+
1. change language to English in RubyForge site's profile page
|
37
|
+
2. make sure ./rubyforge/auto-config.yml contains non-empty processor_ids. If empty, add the data manually.
|
38
|
+
then I can hit 'rake VERSION=x.y.z deploy', all done.
|
39
|
+
It's one button release. great.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: Whitespace compaction mode
|
3
|
+
desc: Whitespace compaction mode for log space saving
|
4
|
+
type: :feature
|
5
|
+
component: twowaysql
|
6
|
+
release:
|
7
|
+
reporter: takuto <takuto.wada@gmail.com>
|
8
|
+
status: :unstarted
|
9
|
+
disposition:
|
10
|
+
creation_time: 2008-09-05 11:32:38.661495 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: 901f65630639507c8b05b466790e9f22256c6450
|
14
|
+
log_events:
|
15
|
+
- - 2008-09-05 11:32:40.738455 Z
|
16
|
+
- takuto <takuto.wada@gmail.com>
|
17
|
+
- created
|
18
|
+
- ""
|
@@ -0,0 +1,30 @@
|
|
1
|
+
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
+
title: change idiom 'substitution' to 'interpolation'
|
3
|
+
desc: "'interpolation' should be better. Thanks Leo."
|
4
|
+
type: :task
|
5
|
+
component: twowaysql
|
6
|
+
release: release_0_2_1
|
7
|
+
reporter: takuto <takuto.wada@gmail.com>
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
|
+
creation_time: 2008-09-05 12:57:18.093242 Z
|
11
|
+
references: []
|
12
|
+
|
13
|
+
id: dca4b19aa13de59838b33e03252bf824670a2d12
|
14
|
+
log_events:
|
15
|
+
- - 2008-09-05 12:57:20.102850 Z
|
16
|
+
- takuto <takuto.wada@gmail.com>
|
17
|
+
- created
|
18
|
+
- ""
|
19
|
+
- - 2008-09-06 07:19:52.293739 Z
|
20
|
+
- takuto <takuto.wada@gmail.com>
|
21
|
+
- changed status from unstarted to in_progress
|
22
|
+
- ""
|
23
|
+
- - 2008-09-06 07:21:02.436063 Z
|
24
|
+
- takuto <takuto.wada@gmail.com>
|
25
|
+
- closed with disposition fixed
|
26
|
+
- ""
|
27
|
+
- - 2008-09-07 16:16:00.691175 Z
|
28
|
+
- takuto <takuto.wada@gmail.com>
|
29
|
+
- assigned to release release_0_2_1 from release_0_3
|
30
|
+
- ""
|
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ditz.rubyforge.org,2008-03-06/issue
|
2
|
-
title: Handle Embedded variable comment at Scanner/
|
3
|
-
desc: Handle Embedded variable comment at Scanner/
|
2
|
+
title: Handle Embedded variable comment at Scanner/Grammar level
|
3
|
+
desc: Handle Embedded variable comment at Scanner/Grammar level. Currently it is handled at Node object level, so Scanner does not know the Substitution comment is Bind variable comment or Embedded variable comment. However Node should not be responsible for that, Scanner/Grammar should do.
|
4
4
|
type: :task
|
5
5
|
component: twowaysql
|
6
|
-
release:
|
6
|
+
release: release_0_2_1
|
7
7
|
reporter: takuto <takuto.wada@gmail.com>
|
8
|
-
status: :
|
9
|
-
disposition:
|
8
|
+
status: :closed
|
9
|
+
disposition: :fixed
|
10
10
|
creation_time: 2008-09-04 19:53:35.026331 Z
|
11
11
|
references: []
|
12
12
|
|
@@ -16,3 +16,19 @@ log_events:
|
|
16
16
|
- takuto <takuto.wada@gmail.com>
|
17
17
|
- created
|
18
18
|
- ""
|
19
|
+
- - 2008-09-05 12:33:44.914741 Z
|
20
|
+
- takuto <takuto.wada@gmail.com>
|
21
|
+
- changed status from unstarted to in_progress
|
22
|
+
- start
|
23
|
+
- - 2008-09-06 04:23:57.911458 Z
|
24
|
+
- takuto <takuto.wada@gmail.com>
|
25
|
+
- closed with disposition fixed
|
26
|
+
- ""
|
27
|
+
- - 2008-09-07 16:12:40.550815 Z
|
28
|
+
- takuto <takuto.wada@gmail.com>
|
29
|
+
- assigned to release release_0_3 from unassigned
|
30
|
+
- ""
|
31
|
+
- - 2008-09-07 16:15:51.826887 Z
|
32
|
+
- takuto <takuto.wada@gmail.com>
|
33
|
+
- assigned to release release_0_2_1 from release_0_3
|
34
|
+
- ""
|
@@ -3,7 +3,7 @@ title: preserve actual comment content
|
|
3
3
|
desc: preserve actual comment content
|
4
4
|
type: :feature
|
5
5
|
component: twowaysql
|
6
|
-
release:
|
6
|
+
release: release_0_3
|
7
7
|
reporter: takuto <takuto.wada@gmail.com>
|
8
8
|
status: :unstarted
|
9
9
|
disposition:
|
@@ -16,3 +16,7 @@ log_events:
|
|
16
16
|
- takuto <takuto.wada@gmail.com>
|
17
17
|
- created
|
18
18
|
- preserve actual comment content if :preserve_comment is on.
|
19
|
+
- - 2008-09-07 14:11:49.991298 Z
|
20
|
+
- takuto <takuto.wada@gmail.com>
|
21
|
+
- assigned to release release_0_3 from unassigned
|
22
|
+
- assign to release_0_3
|
data/issues/project.yaml
CHANGED
@@ -7,10 +7,36 @@ components:
|
|
7
7
|
releases:
|
8
8
|
- !ditz.rubyforge.org,2008-03-06/release
|
9
9
|
name: 0.2 release
|
10
|
-
status: :
|
11
|
-
release_time:
|
10
|
+
status: :released
|
11
|
+
release_time: 2008-09-05 08:08:30.793430 Z
|
12
12
|
log_events:
|
13
13
|
- - 2008-09-03 08:30:15.096853 Z
|
14
14
|
- takuto <takuto.wada@gmail.com>
|
15
15
|
- created
|
16
16
|
- first published version.
|
17
|
+
- - 2008-09-05 08:08:30.793446 Z
|
18
|
+
- takuto <takuto.wada@gmail.com>
|
19
|
+
- released
|
20
|
+
- 0.2 release done.
|
21
|
+
- !ditz.rubyforge.org,2008-03-06/release
|
22
|
+
name: release_0_3
|
23
|
+
status: :unreleased
|
24
|
+
release_time:
|
25
|
+
log_events:
|
26
|
+
- - 2008-09-05 11:23:24.696817 Z
|
27
|
+
- takuto <takuto.wada@gmail.com>
|
28
|
+
- created
|
29
|
+
- release 0.3
|
30
|
+
- !ditz.rubyforge.org,2008-03-06/release
|
31
|
+
name: release_0_2_1
|
32
|
+
status: :released
|
33
|
+
release_time: 2008-09-07 16:48:59.265076 Z
|
34
|
+
log_events:
|
35
|
+
- - 2008-09-07 16:13:59.207476 Z
|
36
|
+
- takuto <takuto.wada@gmail.com>
|
37
|
+
- created
|
38
|
+
- release 0.2.1
|
39
|
+
- - 2008-09-07 16:48:59.265087 Z
|
40
|
+
- takuto <takuto.wada@gmail.com>
|
41
|
+
- released
|
42
|
+
- 0.2.1 release
|
data/lib/twowaysql/node.rb
CHANGED
@@ -1,13 +1,3 @@
|
|
1
|
-
unless String.method_defined?(:start_with?)
|
2
|
-
class String #:nodoc:
|
3
|
-
def start_with?(prefix)
|
4
|
-
prefix = prefix.to_s
|
5
|
-
self[0, prefix.length] == prefix
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
1
|
module TwoWaySQL
|
12
2
|
|
13
3
|
class Context
|
@@ -157,24 +147,13 @@ module TwoWaySQL
|
|
157
147
|
end
|
158
148
|
|
159
149
|
|
160
|
-
class
|
150
|
+
class BindVariableNode < Node
|
161
151
|
def initialize(exp)
|
162
152
|
@exp = exp
|
163
153
|
end
|
164
154
|
def accept(ctx)
|
165
|
-
if @exp.start_with?('$')
|
166
|
-
embed_value(ctx)
|
167
|
-
else
|
168
|
-
substitute(ctx)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
def substitute(ctx)
|
172
155
|
ctx.add_value(do_eval(ctx, @exp))
|
173
156
|
end
|
174
|
-
def embed_value(ctx)
|
175
|
-
result = do_eval(ctx, @exp[1..-1])
|
176
|
-
ctx.add_sql(result) unless result.nil?
|
177
|
-
end
|
178
157
|
end
|
179
158
|
|
180
159
|
|
@@ -188,7 +167,7 @@ module TwoWaySQL
|
|
188
167
|
end
|
189
168
|
|
190
169
|
|
191
|
-
class
|
170
|
+
class ParenBindVariableNode < Node
|
192
171
|
def initialize(exp)
|
193
172
|
@exp = exp
|
194
173
|
end
|
@@ -210,6 +189,17 @@ module TwoWaySQL
|
|
210
189
|
end
|
211
190
|
|
212
191
|
|
192
|
+
class EmbedVariableNode < Node
|
193
|
+
def initialize(exp)
|
194
|
+
@exp = exp
|
195
|
+
end
|
196
|
+
def accept(ctx)
|
197
|
+
result = do_eval(ctx, @exp)
|
198
|
+
ctx.add_sql(result) unless result.nil?
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
|
213
203
|
class LiteralNode < Node
|
214
204
|
def initialize(val)
|
215
205
|
@val = val
|
data/lib/twowaysql/parser.rb
CHANGED
@@ -11,7 +11,7 @@ module TwoWaySQL
|
|
11
11
|
|
12
12
|
class Parser < Racc::Parser
|
13
13
|
|
14
|
-
module_eval <<'..end lib/twowaysql/parser.y modeval..
|
14
|
+
module_eval <<'..end lib/twowaysql/parser.y modeval..id33db4a3791', 'lib/twowaysql/parser.y', 138
|
15
15
|
|
16
16
|
require 'strscan'
|
17
17
|
|
@@ -29,18 +29,20 @@ def initialize(opts={})
|
|
29
29
|
@num_questions = 0
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
PAREN_EXAMPLE
|
34
|
-
|
35
|
-
|
32
|
+
|
33
|
+
PAREN_EXAMPLE = '\([^\)]+\)'
|
34
|
+
BEGIN_BIND_VARIABLE = '(\/|\#)\*([^\*]+)\*\1'
|
35
|
+
BIND_VARIABLE_PATTERN = /\A#{BEGIN_BIND_VARIABLE}\s*/
|
36
|
+
PAREN_BIND_VARIABLE_PATTERN = /\A#{BEGIN_BIND_VARIABLE}\s*#{PAREN_EXAMPLE}/
|
37
|
+
EMBED_VARIABLE_PATTERN = /\A(\/|\#)\*\$([^\*]+)\*\1\s*/
|
36
38
|
|
37
39
|
CONDITIONAL_PATTERN = /\A(\/|\#)\*(IF)\s+([^\*]+)\s*\*\1/
|
38
40
|
BEGIN_END_PATTERN = /\A(\/|\#)\*(BEGIN|END)\s*\*\1/
|
39
|
-
|
41
|
+
STRING_LITERAL_PATTERN = /\A(\'(?:[^\']+|\'\')*\')/ ## quoted string
|
40
42
|
SPLIT_TOKEN_PATTERN = /\A(\S+?)(?=\s*(?:(?:\/|\#)\*|-{2,}|\(|\)|\,))/ ## stop on delimiters --,/*,#*,',',(,)
|
41
43
|
ELSE_PATTERN = /\A\-{2,}\s*ELSE\s*/
|
42
|
-
AND_PATTERN = /\A(\s*AND\s+)/
|
43
|
-
OR_PATTERN = /\A(\s*OR\s+)/
|
44
|
+
AND_PATTERN = /\A(\s*AND\s+)/i
|
45
|
+
OR_PATTERN = /\A(\s*OR\s+)/i
|
44
46
|
LITERAL_PATTERN = /\A([^;\s]+)/
|
45
47
|
SPACES_PATTERN = /\A(\s+)/
|
46
48
|
QUESTION_PATTERN = /\A\?/
|
@@ -54,7 +56,7 @@ UNMATCHED_COMMENT_START_PATTERN = /\A(?:(?:\/|\#)\*)/
|
|
54
56
|
|
55
57
|
def parse( io )
|
56
58
|
@q = []
|
57
|
-
io.
|
59
|
+
io.each_line do |line|
|
58
60
|
s = StringScanner.new(line.rstrip)
|
59
61
|
until s.eos? do
|
60
62
|
case
|
@@ -80,18 +82,20 @@ def parse( io )
|
|
80
82
|
@q.push [ s[2].intern, nil ]
|
81
83
|
when s.scan(CONDITIONAL_PATTERN)
|
82
84
|
@q.push [ s[2].intern, s[3] ]
|
83
|
-
when s.scan(
|
84
|
-
@q.push [ :
|
85
|
-
when s.scan(
|
86
|
-
@q.push [ :
|
87
|
-
when s.scan(
|
88
|
-
@q.push [ :
|
85
|
+
when s.scan(EMBED_VARIABLE_PATTERN)
|
86
|
+
@q.push [ :EMBED_VARIABLE, s[2] ]
|
87
|
+
when s.scan(PAREN_BIND_VARIABLE_PATTERN)
|
88
|
+
@q.push [ :PAREN_BIND_VARIABLE, s[2] ]
|
89
|
+
when s.scan(BIND_VARIABLE_PATTERN)
|
90
|
+
@q.push [ :BIND_VARIABLE, s[2] ]
|
91
|
+
when s.scan(STRING_LITERAL_PATTERN)
|
92
|
+
@q.push [ :STRING_LITERAL, s[1] ]
|
89
93
|
when s.scan(SPLIT_TOKEN_PATTERN)
|
90
|
-
@q.push [ :
|
94
|
+
@q.push [ :IDENT, s[1] ]
|
91
95
|
when s.scan(UNMATCHED_COMMENT_START_PATTERN) ## unmatched comment start, '/*','#*'
|
92
96
|
raise Racc::ParseError, "## unmatched comment. cannot parse [#{s.rest}]"
|
93
97
|
when s.scan(LITERAL_PATTERN) ## other string token
|
94
|
-
@q.push [ :
|
98
|
+
@q.push [ :IDENT, s[1] ]
|
95
99
|
when s.scan(SEMICOLON_AT_INPUT_END_PATTERN)
|
96
100
|
#drop semicolon at input end
|
97
101
|
else
|
@@ -111,104 +115,109 @@ end
|
|
111
115
|
def next_token
|
112
116
|
@q.shift
|
113
117
|
end
|
114
|
-
..end lib/twowaysql/parser.y modeval..
|
118
|
+
..end lib/twowaysql/parser.y modeval..id33db4a3791
|
115
119
|
|
116
120
|
##### racc 1.4.5 generates ###
|
117
121
|
|
118
122
|
racc_reduce_table = [
|
119
123
|
0, 0, :racc_error,
|
120
|
-
1,
|
121
|
-
0,
|
122
|
-
2,
|
123
|
-
1, 22, :_reduce_none,
|
124
|
-
1, 22, :_reduce_none,
|
125
|
-
1, 22, :_reduce_none,
|
126
|
-
3, 25, :_reduce_7,
|
127
|
-
4, 24, :_reduce_8,
|
128
|
-
2, 27, :_reduce_9,
|
129
|
-
0, 27, :_reduce_10,
|
130
|
-
1, 26, :_reduce_none,
|
131
|
-
1, 26, :_reduce_none,
|
132
|
-
1, 26, :_reduce_none,
|
133
|
-
2, 28, :_reduce_14,
|
134
|
-
2, 29, :_reduce_15,
|
135
|
-
1, 23, :_reduce_16,
|
136
|
-
1, 23, :_reduce_17,
|
137
|
-
1, 23, :_reduce_18,
|
138
|
-
1, 23, :_reduce_19,
|
139
|
-
1, 23, :_reduce_20,
|
140
|
-
1, 23, :_reduce_21,
|
141
|
-
1, 23, :_reduce_22,
|
142
|
-
1, 23, :_reduce_23,
|
143
|
-
1, 23, :_reduce_24,
|
144
|
-
1, 23, :_reduce_25,
|
145
|
-
1, 23, :_reduce_26,
|
124
|
+
1, 21, :_reduce_1,
|
125
|
+
0, 22, :_reduce_2,
|
126
|
+
2, 22, :_reduce_3,
|
146
127
|
1, 23, :_reduce_none,
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
128
|
+
1, 23, :_reduce_none,
|
129
|
+
1, 23, :_reduce_none,
|
130
|
+
3, 26, :_reduce_7,
|
131
|
+
4, 25, :_reduce_8,
|
132
|
+
2, 28, :_reduce_9,
|
133
|
+
0, 28, :_reduce_10,
|
134
|
+
1, 27, :_reduce_none,
|
135
|
+
1, 27, :_reduce_none,
|
136
|
+
1, 27, :_reduce_none,
|
137
|
+
2, 29, :_reduce_14,
|
138
|
+
2, 30, :_reduce_15,
|
139
|
+
1, 24, :_reduce_16,
|
140
|
+
1, 24, :_reduce_17,
|
141
|
+
1, 24, :_reduce_18,
|
142
|
+
1, 24, :_reduce_19,
|
143
|
+
1, 24, :_reduce_20,
|
144
|
+
1, 24, :_reduce_21,
|
145
|
+
1, 24, :_reduce_22,
|
146
|
+
1, 24, :_reduce_23,
|
147
|
+
1, 24, :_reduce_24,
|
148
|
+
1, 24, :_reduce_25,
|
149
|
+
1, 24, :_reduce_26,
|
150
|
+
1, 24, :_reduce_none,
|
151
|
+
1, 24, :_reduce_none,
|
152
|
+
2, 31, :_reduce_29,
|
153
|
+
3, 31, :_reduce_30,
|
154
|
+
2, 31, :_reduce_31,
|
155
|
+
3, 31, :_reduce_32,
|
156
|
+
1, 31, :_reduce_33,
|
157
|
+
2, 32, :_reduce_34,
|
158
|
+
3, 32, :_reduce_35 ]
|
159
|
+
|
160
|
+
racc_reduce_n = 36
|
161
|
+
|
162
|
+
racc_shift_n = 49
|
156
163
|
|
157
164
|
racc_action_table = [
|
158
|
-
|
159
|
-
6,
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
4, 6,
|
165
|
-
|
166
|
-
|
167
|
-
|
165
|
+
7, 36, 12, 37, 16, 18, 20, 22, 24, 3,
|
166
|
+
4, 6, 9, 11, 14, 15, 17, 19, 7, 46,
|
167
|
+
12, 40, 16, 18, 20, 22, 24, 3, 4, 6,
|
168
|
+
9, 11, 14, 15, 17, 19, 7, 48, 12, 38,
|
169
|
+
16, 18, 20, 22, 24, 3, 4, 6, 9, 11,
|
170
|
+
14, 15, 17, 19, 7, 39, 12, 25, 16, 18,
|
171
|
+
20, 22, 24, 3, 4, 6, 9, 11, 14, 15,
|
172
|
+
17, 19, 7, nil, 12, nil, 16, 18, 20, 22,
|
173
|
+
24, 3, 4, 6, 9, 11, 14, 15, 17, 19,
|
174
|
+
33, 34, 35, 29, 30, 29, 30, 44, 45 ]
|
168
175
|
|
169
176
|
racc_action_check = [
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
177
|
+
1, 19, 1, 19, 1, 1, 1, 1, 1, 1,
|
178
|
+
1, 1, 1, 1, 1, 1, 1, 1, 43, 37,
|
179
|
+
43, 28, 43, 43, 43, 43, 43, 43, 43, 43,
|
180
|
+
43, 43, 43, 43, 43, 43, 42, 41, 42, 25,
|
181
|
+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
|
182
|
+
42, 42, 42, 42, 26, 26, 26, 2, 26, 26,
|
183
|
+
26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
184
|
+
26, 26, 27, nil, 27, nil, 27, 27, 27, 27,
|
185
|
+
27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
186
|
+
15, 15, 15, 12, 12, 40, 40, 35, 35 ]
|
180
187
|
|
181
188
|
racc_action_pointer = [
|
182
|
-
nil,
|
183
|
-
nil, nil,
|
184
|
-
nil, nil, nil, nil, nil,
|
185
|
-
nil,
|
186
|
-
nil, nil, nil, nil ]
|
189
|
+
nil, -2, 57, nil, nil, nil, nil, nil, nil, nil,
|
190
|
+
nil, nil, 87, nil, nil, 82, nil, nil, nil, -7,
|
191
|
+
nil, nil, nil, nil, nil, 39, 52, 70, 16, nil,
|
192
|
+
nil, nil, nil, nil, nil, 89, nil, 11, nil, nil,
|
193
|
+
89, 34, 34, 16, nil, nil, nil, nil, nil ]
|
187
194
|
|
188
195
|
racc_action_default = [
|
189
|
-
-2,
|
190
|
-
-5, -
|
191
|
-
-
|
192
|
-
|
193
|
-
-
|
196
|
+
-2, -1, -36, -21, -22, -3, -23, -2, -4, -24,
|
197
|
+
-5, -25, -2, -6, -26, -36, -18, -33, -19, -36,
|
198
|
+
-16, -27, -17, -28, -20, -36, -36, -13, -10, -2,
|
199
|
+
-2, -11, -12, -31, -29, -36, -34, -36, 49, -7,
|
200
|
+
-2, -36, -14, -15, -32, -30, -35, -9, -8 ]
|
194
201
|
|
195
202
|
racc_goto_table = [
|
196
|
-
2,
|
203
|
+
1, 2, 41, 28, nil, nil, nil, 26, nil, nil,
|
197
204
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
198
|
-
nil, nil, nil,
|
205
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 42,
|
206
|
+
43, 47 ]
|
199
207
|
|
200
208
|
racc_goto_check = [
|
201
|
-
2,
|
209
|
+
2, 1, 8, 7, nil, nil, nil, 2, nil, nil,
|
202
210
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
203
|
-
nil, nil, nil,
|
211
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 2,
|
212
|
+
2, 7 ]
|
204
213
|
|
205
214
|
racc_goto_pointer = [
|
206
|
-
nil,
|
207
|
-
nil, nil ]
|
215
|
+
nil, 1, 0, nil, nil, nil, nil, -9, -26, nil,
|
216
|
+
nil, nil, nil ]
|
208
217
|
|
209
218
|
racc_goto_default = [
|
210
|
-
nil, nil,
|
211
|
-
|
219
|
+
nil, nil, 27, 5, 8, 10, 13, nil, nil, 31,
|
220
|
+
32, 21, 23 ]
|
212
221
|
|
213
222
|
racc_token_table = {
|
214
223
|
false => 0,
|
@@ -219,8 +228,8 @@ racc_token_table = {
|
|
219
228
|
:ELSE => 5,
|
220
229
|
:AND => 6,
|
221
230
|
:OR => 7,
|
222
|
-
:
|
223
|
-
:
|
231
|
+
:IDENT => 8,
|
232
|
+
:STRING_LITERAL => 9,
|
224
233
|
:SPACES => 10,
|
225
234
|
:COMMA => 11,
|
226
235
|
:LPAREN => 12,
|
@@ -228,12 +237,13 @@ racc_token_table = {
|
|
228
237
|
:QUESTION => 14,
|
229
238
|
:ACTUAL_COMMENT => 15,
|
230
239
|
:EOL => 16,
|
231
|
-
:
|
232
|
-
:
|
240
|
+
:BIND_VARIABLE => 17,
|
241
|
+
:PAREN_BIND_VARIABLE => 18,
|
242
|
+
:EMBED_VARIABLE => 19 }
|
233
243
|
|
234
244
|
racc_use_result_var = true
|
235
245
|
|
236
|
-
racc_nt_base =
|
246
|
+
racc_nt_base = 20
|
237
247
|
|
238
248
|
Racc_arg = [
|
239
249
|
racc_action_table,
|
@@ -260,8 +270,8 @@ Racc_token_to_s_table = [
|
|
260
270
|
'ELSE',
|
261
271
|
'AND',
|
262
272
|
'OR',
|
263
|
-
'
|
264
|
-
'
|
273
|
+
'IDENT',
|
274
|
+
'STRING_LITERAL',
|
265
275
|
'SPACES',
|
266
276
|
'COMMA',
|
267
277
|
'LPAREN',
|
@@ -269,8 +279,9 @@ Racc_token_to_s_table = [
|
|
269
279
|
'QUESTION',
|
270
280
|
'ACTUAL_COMMENT',
|
271
281
|
'EOL',
|
272
|
-
'
|
273
|
-
'
|
282
|
+
'BIND_VARIABLE',
|
283
|
+
'PAREN_BIND_VARIABLE',
|
284
|
+
'EMBED_VARIABLE',
|
274
285
|
'$start',
|
275
286
|
'sql',
|
276
287
|
'stmt_list',
|
@@ -282,7 +293,8 @@ Racc_token_to_s_table = [
|
|
282
293
|
'else_stmt',
|
283
294
|
'and_stmt',
|
284
295
|
'or_stmt',
|
285
|
-
'
|
296
|
+
'bind_var',
|
297
|
+
'embed_var']
|
286
298
|
|
287
299
|
Racc_debug_parser = false
|
288
300
|
|
@@ -445,37 +457,53 @@ module_eval <<'.,.,', 'lib/twowaysql/parser.y', 100
|
|
445
457
|
|
446
458
|
# reduce 27 omitted
|
447
459
|
|
448
|
-
|
449
|
-
def _reduce_28( val, _values, result )
|
450
|
-
result = SubstitutionNode.new( val[0] )
|
451
|
-
result
|
452
|
-
end
|
453
|
-
.,.,
|
460
|
+
# reduce 28 omitted
|
454
461
|
|
455
|
-
module_eval <<'.,.,', 'lib/twowaysql/parser.y',
|
462
|
+
module_eval <<'.,.,', 'lib/twowaysql/parser.y', 107
|
456
463
|
def _reduce_29( val, _values, result )
|
457
|
-
result =
|
464
|
+
result = BindVariableNode.new( val[0] )
|
458
465
|
result
|
459
466
|
end
|
460
467
|
.,.,
|
461
468
|
|
462
|
-
module_eval <<'.,.,', 'lib/twowaysql/parser.y',
|
469
|
+
module_eval <<'.,.,', 'lib/twowaysql/parser.y', 111
|
463
470
|
def _reduce_30( val, _values, result )
|
464
|
-
result =
|
471
|
+
result = BindVariableNode.new( val[0] )
|
465
472
|
result
|
466
473
|
end
|
467
474
|
.,.,
|
468
475
|
|
469
|
-
module_eval <<'.,.,', 'lib/twowaysql/parser.y',
|
476
|
+
module_eval <<'.,.,', 'lib/twowaysql/parser.y', 115
|
470
477
|
def _reduce_31( val, _values, result )
|
471
|
-
result =
|
478
|
+
result = BindVariableNode.new( val[0] )
|
472
479
|
result
|
473
480
|
end
|
474
481
|
.,.,
|
475
482
|
|
476
|
-
module_eval <<'.,.,', 'lib/twowaysql/parser.y',
|
483
|
+
module_eval <<'.,.,', 'lib/twowaysql/parser.y', 119
|
477
484
|
def _reduce_32( val, _values, result )
|
478
|
-
result =
|
485
|
+
result = BindVariableNode.new( val[0] )
|
486
|
+
result
|
487
|
+
end
|
488
|
+
.,.,
|
489
|
+
|
490
|
+
module_eval <<'.,.,', 'lib/twowaysql/parser.y', 123
|
491
|
+
def _reduce_33( val, _values, result )
|
492
|
+
result = ParenBindVariableNode.new( val[0] )
|
493
|
+
result
|
494
|
+
end
|
495
|
+
.,.,
|
496
|
+
|
497
|
+
module_eval <<'.,.,', 'lib/twowaysql/parser.y', 128
|
498
|
+
def _reduce_34( val, _values, result )
|
499
|
+
result = EmbedVariableNode.new( val[0] )
|
500
|
+
result
|
501
|
+
end
|
502
|
+
.,.,
|
503
|
+
|
504
|
+
module_eval <<'.,.,', 'lib/twowaysql/parser.y', 132
|
505
|
+
def _reduce_35( val, _values, result )
|
506
|
+
result = EmbedVariableNode.new( val[0] )
|
479
507
|
result
|
480
508
|
end
|
481
509
|
.,.,
|
data/lib/twowaysql/parser.y
CHANGED
@@ -53,11 +53,11 @@ or_stmt : OR stmt_list
|
|
53
53
|
result = SubStatementNode.new( val[0], val[1] )
|
54
54
|
}
|
55
55
|
|
56
|
-
primary :
|
56
|
+
primary : IDENT
|
57
57
|
{
|
58
58
|
result = LiteralNode.new( val[0] )
|
59
59
|
}
|
60
|
-
|
|
60
|
+
| STRING_LITERAL
|
61
61
|
{
|
62
62
|
result = LiteralNode.new( val[0] )
|
63
63
|
}
|
@@ -98,27 +98,37 @@ primary : CHARS
|
|
98
98
|
{
|
99
99
|
result = EolNode.new
|
100
100
|
}
|
101
|
-
|
|
101
|
+
| bind_var
|
102
|
+
| embed_var
|
102
103
|
|
103
|
-
|
104
|
+
bind_var : BIND_VARIABLE STRING_LITERAL
|
104
105
|
{
|
105
|
-
result =
|
106
|
+
result = BindVariableNode.new( val[0] )
|
106
107
|
}
|
107
|
-
|
|
108
|
+
| BIND_VARIABLE SPACES STRING_LITERAL
|
108
109
|
{
|
109
|
-
result =
|
110
|
+
result = BindVariableNode.new( val[0] )
|
110
111
|
}
|
111
|
-
|
|
112
|
+
| BIND_VARIABLE IDENT
|
112
113
|
{
|
113
|
-
result =
|
114
|
+
result = BindVariableNode.new( val[0] )
|
114
115
|
}
|
115
|
-
|
|
116
|
+
| BIND_VARIABLE SPACES IDENT
|
116
117
|
{
|
117
|
-
result =
|
118
|
+
result = BindVariableNode.new( val[0] )
|
118
119
|
}
|
119
|
-
|
|
120
|
+
| PAREN_BIND_VARIABLE
|
120
121
|
{
|
121
|
-
result =
|
122
|
+
result = ParenBindVariableNode.new( val[0] )
|
123
|
+
}
|
124
|
+
|
125
|
+
embed_var : EMBED_VARIABLE IDENT
|
126
|
+
{
|
127
|
+
result = EmbedVariableNode.new( val[0] )
|
128
|
+
}
|
129
|
+
| EMBED_VARIABLE SPACES IDENT
|
130
|
+
{
|
131
|
+
result = EmbedVariableNode.new( val[0] )
|
122
132
|
}
|
123
133
|
|
124
134
|
end
|
@@ -142,18 +152,20 @@ def initialize(opts={})
|
|
142
152
|
@num_questions = 0
|
143
153
|
end
|
144
154
|
|
145
|
-
|
146
|
-
PAREN_EXAMPLE
|
147
|
-
|
148
|
-
|
155
|
+
|
156
|
+
PAREN_EXAMPLE = '\([^\)]+\)'
|
157
|
+
BEGIN_BIND_VARIABLE = '(\/|\#)\*([^\*]+)\*\1'
|
158
|
+
BIND_VARIABLE_PATTERN = /\A#{BEGIN_BIND_VARIABLE}\s*/
|
159
|
+
PAREN_BIND_VARIABLE_PATTERN = /\A#{BEGIN_BIND_VARIABLE}\s*#{PAREN_EXAMPLE}/
|
160
|
+
EMBED_VARIABLE_PATTERN = /\A(\/|\#)\*\$([^\*]+)\*\1\s*/
|
149
161
|
|
150
162
|
CONDITIONAL_PATTERN = /\A(\/|\#)\*(IF)\s+([^\*]+)\s*\*\1/
|
151
163
|
BEGIN_END_PATTERN = /\A(\/|\#)\*(BEGIN|END)\s*\*\1/
|
152
|
-
|
164
|
+
STRING_LITERAL_PATTERN = /\A(\'(?:[^\']+|\'\')*\')/ ## quoted string
|
153
165
|
SPLIT_TOKEN_PATTERN = /\A(\S+?)(?=\s*(?:(?:\/|\#)\*|-{2,}|\(|\)|\,))/ ## stop on delimiters --,/*,#*,',',(,)
|
154
166
|
ELSE_PATTERN = /\A\-{2,}\s*ELSE\s*/
|
155
|
-
AND_PATTERN = /\A(\s*AND\s+)/
|
156
|
-
OR_PATTERN = /\A(\s*OR\s+)/
|
167
|
+
AND_PATTERN = /\A(\s*AND\s+)/i
|
168
|
+
OR_PATTERN = /\A(\s*OR\s+)/i
|
157
169
|
LITERAL_PATTERN = /\A([^;\s]+)/
|
158
170
|
SPACES_PATTERN = /\A(\s+)/
|
159
171
|
QUESTION_PATTERN = /\A\?/
|
@@ -167,7 +179,7 @@ UNMATCHED_COMMENT_START_PATTERN = /\A(?:(?:\/|\#)\*)/
|
|
167
179
|
|
168
180
|
def parse( io )
|
169
181
|
@q = []
|
170
|
-
io.
|
182
|
+
io.each_line do |line|
|
171
183
|
s = StringScanner.new(line.rstrip)
|
172
184
|
until s.eos? do
|
173
185
|
case
|
@@ -193,18 +205,20 @@ def parse( io )
|
|
193
205
|
@q.push [ s[2].intern, nil ]
|
194
206
|
when s.scan(CONDITIONAL_PATTERN)
|
195
207
|
@q.push [ s[2].intern, s[3] ]
|
196
|
-
when s.scan(
|
197
|
-
@q.push [ :
|
198
|
-
when s.scan(
|
199
|
-
@q.push [ :
|
200
|
-
when s.scan(
|
201
|
-
@q.push [ :
|
208
|
+
when s.scan(EMBED_VARIABLE_PATTERN)
|
209
|
+
@q.push [ :EMBED_VARIABLE, s[2] ]
|
210
|
+
when s.scan(PAREN_BIND_VARIABLE_PATTERN)
|
211
|
+
@q.push [ :PAREN_BIND_VARIABLE, s[2] ]
|
212
|
+
when s.scan(BIND_VARIABLE_PATTERN)
|
213
|
+
@q.push [ :BIND_VARIABLE, s[2] ]
|
214
|
+
when s.scan(STRING_LITERAL_PATTERN)
|
215
|
+
@q.push [ :STRING_LITERAL, s[1] ]
|
202
216
|
when s.scan(SPLIT_TOKEN_PATTERN)
|
203
|
-
@q.push [ :
|
217
|
+
@q.push [ :IDENT, s[1] ]
|
204
218
|
when s.scan(UNMATCHED_COMMENT_START_PATTERN) ## unmatched comment start, '/*','#*'
|
205
219
|
raise Racc::ParseError, "## unmatched comment. cannot parse [#{s.rest}]"
|
206
220
|
when s.scan(LITERAL_PATTERN) ## other string token
|
207
|
-
@q.push [ :
|
221
|
+
@q.push [ :IDENT, s[1] ]
|
208
222
|
when s.scan(SEMICOLON_AT_INPUT_END_PATTERN)
|
209
223
|
#drop semicolon at input end
|
210
224
|
else
|
data/lib/twowaysql/version.rb
CHANGED
data/spec/large_sql_spec.rb
CHANGED
@@ -21,7 +21,7 @@ FROM
|
|
21
21
|
ON i.id = h.item_id
|
22
22
|
|
23
23
|
/*BEGIN*/WHERE
|
24
|
-
/*IF ctx[:name] */
|
24
|
+
/*IF ctx[:name] */i.name ILIKE /*ctx[:name]*/'hoge%'/*END*/
|
25
25
|
/*IF ctx[:display_name] */AND d.display_name ILIKE /*ctx[:display_name]*/'hoge%'/*END*/
|
26
26
|
/*IF ctx[:status] */AND h.status IN /*ctx[:status]*/(3, 4, 9)/*END*/
|
27
27
|
/*IF ctx[:ignore_status] */AND h.status NOT IN /*ctx[:ignore_status]*/(4, 9)/*END*/
|
@@ -139,4 +139,38 @@ EOS
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
+
|
143
|
+
|
144
|
+
describe "bugfix: case insensitive match for SQL reserved words" do
|
145
|
+
before do
|
146
|
+
sql = <<-EOS
|
147
|
+
select
|
148
|
+
*
|
149
|
+
from
|
150
|
+
hoge
|
151
|
+
/*BEGIN*/where
|
152
|
+
/*IF ctx[:name] */name like /*ctx[:name]*/'hoge%'/*END*/
|
153
|
+
/*IF ctx[:id_list] */and id in /*ctx[:id_list]*/(3, 4, 9)/*END*/
|
154
|
+
/*END*/
|
155
|
+
EOS
|
156
|
+
template = TwoWaySQL::Template.parse(sql)
|
157
|
+
@result = template.merge(:id_list => [10, 11])
|
158
|
+
end
|
159
|
+
|
160
|
+
it "sql" do
|
161
|
+
expected = <<-EOS
|
162
|
+
select
|
163
|
+
*
|
164
|
+
from
|
165
|
+
hoge
|
166
|
+
where
|
167
|
+
|
168
|
+
id in (?, ?)
|
169
|
+
|
170
|
+
EOS
|
171
|
+
@result.sql.should == expected
|
172
|
+
@result.bound_variables.should == [10, 11]
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
142
176
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,3 +8,36 @@ end
|
|
8
8
|
|
9
9
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
10
10
|
require 'twowaysql'
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## workaround for RSpec with ruby 1.9 cause 'wrong argument type Proc (expected Binding) (TypeError)'
|
15
|
+
#
|
16
|
+
# before:
|
17
|
+
# params[:spec_path] = eval("caller(0)[1]", example_group_block) unless params[:spec_path]
|
18
|
+
# after:
|
19
|
+
# params[:spec_path] = eval("caller(0)[1]", example_group_block.binding) unless params[:spec_path]
|
20
|
+
#
|
21
|
+
module Spec::Example::ExampleGroupMethods
|
22
|
+
|
23
|
+
def describe(*args, &example_group_block)
|
24
|
+
args << {} unless Hash === args.last
|
25
|
+
if example_group_block
|
26
|
+
params = args.last
|
27
|
+
params[:spec_path] = eval("caller(0)[1]", example_group_block.binding) unless params[:spec_path]
|
28
|
+
if params[:shared]
|
29
|
+
SharedExampleGroup.new(*args, &example_group_block)
|
30
|
+
else
|
31
|
+
self.subclass("Subclass") do
|
32
|
+
describe(*args)
|
33
|
+
module_eval(&example_group_block)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
else
|
37
|
+
set_description(*args)
|
38
|
+
before_eval
|
39
|
+
self
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/tasks/deployment.rake
CHANGED
data/tasks/ditz.rake
CHANGED
data/tasks/website.rake
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
desc 'Generate website files'
|
2
|
-
task :website_generate => :ruby_env do
|
2
|
+
task :website_generate => [:ruby_env,:ditz_report] do
|
3
3
|
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
4
|
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
5
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twowaysql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takuto Wada
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-08 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,11 +42,16 @@ files:
|
|
42
42
|
- Rakefile
|
43
43
|
- config/hoe.rb
|
44
44
|
- config/requirements.rb
|
45
|
+
- issues/issue-1cee7e821865a216674832b0186bd92792680571.yaml
|
45
46
|
- issues/issue-25efcfc383f3b0f6c0e2730ae7c2975bb2b3de26.yaml
|
46
47
|
- issues/issue-39023ea09e17e2d64bcef03aa59cdfe38b78ad5b.yaml
|
47
48
|
- issues/issue-4bc308d55ae91f266e656162a4147d356de1166c.yaml
|
49
|
+
- issues/issue-5c973ef5bb074eacca0c6c84f7d27c4267773ea8.yaml
|
50
|
+
- issues/issue-664986b219202ff1948cab717b56e7540f493561.yaml
|
48
51
|
- issues/issue-897995fa10377eabdf597e8e7692f17087c76923.yaml
|
52
|
+
- issues/issue-901f65630639507c8b05b466790e9f22256c6450.yaml
|
49
53
|
- issues/issue-bd38c1cdc965d73dd629a81db2de1bcdcf4b10b8.yaml
|
54
|
+
- issues/issue-dca4b19aa13de59838b33e03252bf824670a2d12.yaml
|
50
55
|
- issues/issue-f2b773020b54f839c03d899b38b5113c8fd991df.yaml
|
51
56
|
- issues/issue-f39b907d01d7fa93df8c7a9de2e1b5e27727ee0a.yaml
|
52
57
|
- issues/issue-f64d73ed4f9854f1ded77e6496dbf59cfb3770a7.yaml
|