sdbcli 1.4.9 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/sdbcli +14 -5
- metadata +1 -1
data/bin/sdbcli
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
3
3
|
|
4
|
-
Version = '1.
|
4
|
+
Version = '1.5.0'
|
5
5
|
HISTORY_FILE = File.join((ENV['HOME'] || ENV['USERPROFILE'] || '.'), '.sdbcli_history')
|
6
6
|
HISTSIZE = 500
|
7
7
|
SELECT_LIMIT = 2500
|
@@ -75,10 +75,12 @@ end
|
|
75
75
|
def execute(src, show_rows = false)
|
76
76
|
ss = StringScanner.new(src.dup)
|
77
77
|
buf = ''
|
78
|
+
script = false
|
78
79
|
|
79
80
|
until ss.eos?
|
80
81
|
if (tok = ss.scan %r{[^-.`'";\\/#]+}) #'
|
81
82
|
buf << tok
|
83
|
+
script = true if tok =~ /[|!]/
|
82
84
|
elsif (tok = ss.scan /`(?:[^`]|``)*`/)
|
83
85
|
buf << tok
|
84
86
|
elsif (tok = ss.scan /'(?:[^']|'')*'/) #'
|
@@ -97,6 +99,7 @@ def execute(src, show_rows = false)
|
|
97
99
|
src.replace(ss.rest)
|
98
100
|
query = buf
|
99
101
|
buf = ''
|
102
|
+
script = false
|
100
103
|
|
101
104
|
if tok == '\G'
|
102
105
|
inline = false
|
@@ -172,12 +175,18 @@ def execute(src, show_rows = false)
|
|
172
175
|
puts str
|
173
176
|
end
|
174
177
|
elsif (tok = ss.scan /[-.]/)
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
178
|
+
if script
|
179
|
+
buf << tok
|
180
|
+
else
|
181
|
+
output_error 'You must quote attributes and domain names that contain characters other than letters, numbers, underscores (_), or dollar symbols ($) with the backtick (`)'
|
182
|
+
ss.scan_until(/(?:;|\\G|\Z)/)
|
183
|
+
src.replace(ss.rest)
|
184
|
+
buf = ''
|
185
|
+
script = false
|
186
|
+
end
|
179
187
|
elsif (tok = ss.scan /./)
|
180
188
|
buf << tok
|
189
|
+
script = true if tok =~ /[|!]/
|
181
190
|
end
|
182
191
|
end
|
183
192
|
|