flydata 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/flydata.gemspec +3 -3
- data/lib/flydata/parser/mysql/mysql_alter_table.treetop +47 -4
- data/spec/flydata/parser/mysql/alter_table_parser_spec.rb +152 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c8db01831bbe6064e91787631ec6bb0e943adcf
|
4
|
+
data.tar.gz: 9d2693f29f27ddc50606aad9092aa858e03aa794
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1491e172b4e48f320eeea818e26dd78c6ab932686d12bd82fa1bea9bf9f65062802efa49ec83b4dc6384c0ee2a01aa0841ed13df8a0e96a802179711ea801e3c
|
7
|
+
data.tar.gz: c095c18ac4bda4be13c36a7cb03348e62b1fedde7bea01ff400b81e854516484910c8455d49be54f46881c6767215c5b9a62cbdb53b435e697f7093107cd8f7c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/flydata.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: flydata 0.2.
|
5
|
+
# stub: flydata 0.2.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "flydata"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.4"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Koichi Fujikawa"]
|
14
|
-
s.date = "2014-09-
|
14
|
+
s.date = "2014-09-17"
|
15
15
|
s.description = "FlyData Command Line Interface"
|
16
16
|
s.email = "sysadmin@flydata.co"
|
17
17
|
s.executables = ["fdmysqldump", "flydata", "serverinfo"]
|
@@ -202,8 +202,51 @@ grammar MysqlAlterTable
|
|
202
202
|
'default'i sp default_value { def default_opt_option; { default: default_value.default_value }; end }
|
203
203
|
end
|
204
204
|
rule default_value
|
205
|
-
|
206
|
-
/
|
205
|
+
now { def default_value; text_value; end }
|
206
|
+
/ signed_literal { def default_value; text_value; end }
|
207
|
+
end
|
208
|
+
rule now
|
209
|
+
'current_timestamp'i
|
210
|
+
/ 'localtimestamp'i { def text_value; 'current_timestamp'; end }
|
211
|
+
/ 'localtime'i { def text_value; 'current_timestamp'; end }
|
212
|
+
/ 'now()'i { def text_value; 'current_timestamp'; end }
|
213
|
+
end
|
214
|
+
rule signed_literal
|
215
|
+
literal
|
216
|
+
/ '+' num_literal { def text_value; num_literal.text_value; end }
|
217
|
+
/ '-' num_literal { def text_value; "-#{num_literal.text_value}"; end }
|
218
|
+
end
|
219
|
+
rule literal
|
220
|
+
text_literal
|
221
|
+
/ num_literal
|
222
|
+
# / temporal_literal # TODO
|
223
|
+
/ null_sym
|
224
|
+
/ false_sym
|
225
|
+
/ true_sym
|
226
|
+
# / hex_num # TODO
|
227
|
+
# / bin_num # TODO
|
228
|
+
# / underscore_charset hex_num # TODO
|
229
|
+
# / underscore_charset bin_num # TODO
|
230
|
+
end
|
231
|
+
rule text_literal
|
232
|
+
quoted_value { def text_value; text_raw_value; end }
|
233
|
+
# text_string # TODO
|
234
|
+
# / nchar_string # TODO
|
235
|
+
# / underscore_charset text_string # TODO
|
236
|
+
# / text_literal text_string_literal # TODO
|
237
|
+
end
|
238
|
+
rule null_sym
|
239
|
+
'null'i { def text_value; nil; end }
|
240
|
+
end
|
241
|
+
rule false_sym
|
242
|
+
'false'i
|
243
|
+
end
|
244
|
+
rule true_sym
|
245
|
+
'true'i
|
246
|
+
end
|
247
|
+
rule num_literal
|
248
|
+
[0-9]* '.' [0-9]+ { def text_value; v = super; v.start_with?('.') ? "0#{v}" : v; end }
|
249
|
+
/ [0-9]+
|
207
250
|
end
|
208
251
|
rule auto_increment_opt
|
209
252
|
'auto_increment'i
|
@@ -286,11 +329,11 @@ grammar MysqlAlterTable
|
|
286
329
|
end
|
287
330
|
|
288
331
|
rule quoted_value
|
289
|
-
'
|
332
|
+
"'" text "'" { def text_raw_value; text.text_value; end }
|
290
333
|
end
|
291
334
|
|
292
335
|
rule text
|
293
|
-
( '
|
336
|
+
("\\\\" / "\\'" / !"'" .)*
|
294
337
|
end
|
295
338
|
|
296
339
|
rule ident_sys
|
@@ -210,19 +210,158 @@ describe 'MysqlAlterTableParser' do
|
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
|
-
context
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
213
|
+
context "with default option" do
|
214
|
+
shared_examples "a query parser parsing a query adding a column with a default value" do
|
215
|
+
let(:query) { "alter table test_table add column col #{data_type} default #{value}" }
|
216
|
+
it do
|
217
|
+
expect(subject).to eq({
|
218
|
+
type: :alter_table,
|
219
|
+
table_name: "test_table",
|
220
|
+
actions: [{
|
221
|
+
action: :add_column,
|
222
|
+
column: "col",
|
223
|
+
type: expected_data_type,
|
224
|
+
default: expected_value,
|
225
|
+
}]
|
226
|
+
})
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
context 'for timestamp column' do
|
231
|
+
let(:data_type) { "timestamp" }
|
232
|
+
let(:expected_data_type) { "datetime" }
|
233
|
+
context 'taking current_timestamp' do
|
234
|
+
let(:value) { "current_timestamp" }
|
235
|
+
let(:expected_value) { "current_timestamp" }
|
236
|
+
|
237
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
238
|
+
end
|
239
|
+
context 'taking localtime' do
|
240
|
+
let(:value) { "localtime" }
|
241
|
+
let(:expected_value) { "current_timestamp" }
|
242
|
+
|
243
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
244
|
+
end
|
245
|
+
context 'taking localtimestamp' do
|
246
|
+
let(:value) { "localtimestamp" }
|
247
|
+
let(:expected_value) { "current_timestamp" }
|
248
|
+
|
249
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
250
|
+
end
|
251
|
+
context 'taking now()' do
|
252
|
+
let(:value) { "now()" }
|
253
|
+
let(:expected_value) { "current_timestamp" }
|
254
|
+
|
255
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context 'for integer column' do
|
260
|
+
let(:data_type) { "int(11)" }
|
261
|
+
let(:expected_data_type) { "int4(11)" }
|
262
|
+
|
263
|
+
context 'taking a positive number without sign' do
|
264
|
+
let(:value) { "1" }
|
265
|
+
let(:expected_value) { "1" }
|
266
|
+
|
267
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
268
|
+
end
|
269
|
+
context 'taking a positive number' do
|
270
|
+
let(:value) { "+1" }
|
271
|
+
let(:expected_value) { "1" }
|
272
|
+
|
273
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
274
|
+
end
|
275
|
+
context 'taking a negative number' do
|
276
|
+
let(:value) { "-1" }
|
277
|
+
let(:expected_value) { "-1" }
|
278
|
+
|
279
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
280
|
+
end
|
281
|
+
context 'taking a negative number string' do
|
282
|
+
let(:value) { %Q|'-1'| }
|
283
|
+
let(:expected_value) { "-1" }
|
284
|
+
|
285
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
286
|
+
end
|
287
|
+
context 'taking null' do
|
288
|
+
let(:value) { %Q|NULL| }
|
289
|
+
let(:expected_value) { nil }
|
290
|
+
|
291
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
context 'for decimal column' do
|
296
|
+
let(:data_type) { "decimal(10,2)" }
|
297
|
+
let(:expected_data_type) { "numeric(10,2)" }
|
298
|
+
|
299
|
+
context 'taking a positive number without sign' do
|
300
|
+
let(:value) { "2.4" }
|
301
|
+
let(:expected_value) { "2.4" }
|
302
|
+
|
303
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
304
|
+
end
|
305
|
+
context 'taking a positive number with sign' do
|
306
|
+
let(:value) { "+0.4" }
|
307
|
+
let(:expected_value) { "0.4" }
|
308
|
+
|
309
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
310
|
+
end
|
311
|
+
context 'taking a positive number no integer part' do
|
312
|
+
let(:value) { ".05" }
|
313
|
+
let(:expected_value) { "0.05" }
|
314
|
+
|
315
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
316
|
+
end
|
317
|
+
context 'taking a negative number' do
|
318
|
+
let(:value) { "-20.43" }
|
319
|
+
let(:expected_value) { "-20.43" }
|
320
|
+
|
321
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
322
|
+
end
|
323
|
+
context 'taking a negative number no integer part' do
|
324
|
+
let(:value) { "-.43" }
|
325
|
+
let(:expected_value) { "-0.43" }
|
326
|
+
|
327
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
context 'for varchar column' do
|
332
|
+
let(:data_type) { "varchar(10)" }
|
333
|
+
let(:expected_data_type) { "varchar(30)" }
|
334
|
+
|
335
|
+
context 'taking null' do
|
336
|
+
let(:value) { "NULL" }
|
337
|
+
let(:expected_value) { nil }
|
338
|
+
|
339
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
340
|
+
end
|
341
|
+
context 'taking empty string' do
|
342
|
+
let(:value) { %Q|''| }
|
343
|
+
let(:expected_value) { "" }
|
344
|
+
|
345
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
346
|
+
end
|
347
|
+
context 'taking a string with spaces' do
|
348
|
+
let(:value) { %Q|'0 0 0 0 0 0 0'| }
|
349
|
+
let(:expected_value) { "0 0 0 0 0 0 0" }
|
350
|
+
|
351
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
352
|
+
end
|
353
|
+
context 'taking a backslash' do
|
354
|
+
let(:value) { %q|'\\\\'| }
|
355
|
+
let(:expected_value) { %q|\\\\| }
|
356
|
+
|
357
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
358
|
+
end
|
359
|
+
context 'taking a string with special characters' do
|
360
|
+
let(:value) { %q|'https://flydata.com $ \\\\\'\"\n\t'| }
|
361
|
+
let(:expected_value) { %q|https://flydata.com $ \\\\\'\"\n\t| }
|
362
|
+
|
363
|
+
it_behaves_like "a query parser parsing a query adding a column with a default value"
|
364
|
+
end
|
226
365
|
end
|
227
366
|
end
|
228
367
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flydata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Fujikawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|