flydata 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/flydata.gemspec +15 -3
- data/lib/flydata/cli.rb +1 -1
- data/lib/flydata/command/sender.rb +35 -10
- data/lib/flydata/command/sync.rb +188 -24
- data/lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb +101 -218
- data/lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb +34 -0
- data/lib/flydata/fluent-plugins/mysql/binlog_position.rb +20 -0
- data/lib/flydata/fluent-plugins/mysql/binlog_query_dispatcher.rb +39 -0
- data/lib/flydata/fluent-plugins/mysql/binlog_query_handler.rb +11 -0
- data/lib/flydata/fluent-plugins/mysql/binlog_record_dispatcher.rb +50 -0
- data/lib/flydata/fluent-plugins/mysql/binlog_record_handler.rb +100 -0
- data/lib/flydata/fluent-plugins/mysql/context.rb +25 -0
- data/lib/flydata/fluent-plugins/mysql/dml_record_handler.rb +82 -0
- data/lib/flydata/fluent-plugins/mysql/query_parser.rb +69 -0
- data/lib/flydata/sync_file_manager.rb +119 -12
- data/lib/flydata/table_def/mysql_table_def.rb +52 -22
- data/lib/flydata/table_def/redshift_table_def.rb +17 -9
- data/spec/flydata/command/sync_spec.rb +5 -5
- data/spec/flydata/fluent-plugins/in_mysql_binlog_flydata_spec.rb +86 -15
- data/spec/flydata/fluent-plugins/mysql/binlog_position_spec.rb +33 -0
- data/spec/flydata/fluent-plugins/mysql/query_parser_spec.rb +54 -0
- data/spec/flydata/table_def/mysql_table_def_spec.rb +2 -2
- data/spec/flydata/table_def/redshift_table_def_spec.rb +40 -0
- metadata +16 -4
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative '../../../spec_helper'
|
2
|
+
|
3
|
+
module Mysql
|
4
|
+
describe AlterTableAddColumnParser do
|
5
|
+
describe '#parse' do
|
6
|
+
let(:query) { "" }
|
7
|
+
subject { AlterTableAddColumnParser.new.parse(query) }
|
8
|
+
|
9
|
+
context 'with normal alter table query' do
|
10
|
+
let(:query) { "alter table test_table add column value varchar(26)" }
|
11
|
+
it do
|
12
|
+
expect(subject).to eq([{
|
13
|
+
:subtype => :add_column,
|
14
|
+
:table_name => "test_table",
|
15
|
+
:column => {
|
16
|
+
:name => "value",
|
17
|
+
:type => "varchar(78)"
|
18
|
+
}
|
19
|
+
}])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with after option' do
|
24
|
+
let(:query) { "alter table test_table add column value varchar(26) after id" }
|
25
|
+
it do
|
26
|
+
expect(subject).to eq([{
|
27
|
+
:subtype => :add_column,
|
28
|
+
:table_name => "test_table",
|
29
|
+
:column => {
|
30
|
+
:name => "value",
|
31
|
+
:type => "varchar(78)",
|
32
|
+
:after => "id"
|
33
|
+
}
|
34
|
+
}])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'with first option' do
|
39
|
+
let(:query) { "alter table test_table add column value varchar(26) first" }
|
40
|
+
it do
|
41
|
+
expect(subject).to eq([{
|
42
|
+
:subtype => :add_column,
|
43
|
+
:table_name => "test_table",
|
44
|
+
:column => {
|
45
|
+
:name => "value",
|
46
|
+
:type => "varchar(78)",
|
47
|
+
:position => :first
|
48
|
+
}
|
49
|
+
}])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -34,7 +34,7 @@ describe MysqlTableDef do
|
|
34
34
|
{:name=>"col_binary", :type=>"binary(100)", :default=>nil},
|
35
35
|
{:name=>"col_blob", :type=>"varbinary"},
|
36
36
|
{:name=>"col_bool", :type=>"int1(1)", :default=>"0"},
|
37
|
-
{:name=>"col_char", :type=>"varchar(
|
37
|
+
{:name=>"col_char", :type=>"varchar(18)", :default=>nil},
|
38
38
|
{:name=>"col_date", :type=>"date", :default=>nil},
|
39
39
|
{:name=>"col_datetime", :type=>"datetime", :default=>nil},
|
40
40
|
{:name=>"col_decimal", :type=>"numeric(5,2)", :default=>nil},
|
@@ -56,7 +56,7 @@ describe MysqlTableDef do
|
|
56
56
|
{:name=>"col_tinyint", :type=>"int1(4)", :default=>nil},
|
57
57
|
{:name=>"col_tinytext", :type=>"text"},
|
58
58
|
{:name=>"col_varbinary", :type=>"varbinary(255)", :default=>nil},
|
59
|
-
{:name=>"col_varchar", :type=>"varchar(
|
59
|
+
{:name=>"col_varchar", :type=>"varchar(372)", :default=>nil}
|
60
60
|
]
|
61
61
|
)
|
62
62
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'flydata/table_def'
|
3
|
+
|
4
|
+
module Flydata
|
5
|
+
module TableDef
|
6
|
+
|
7
|
+
describe RedshiftTableDef do
|
8
|
+
|
9
|
+
describe '.column_def_sql' do
|
10
|
+
let(:column) { {} }
|
11
|
+
subject { described_class.column_def_sql(column) }
|
12
|
+
|
13
|
+
context 'with varchar column def' do
|
14
|
+
context 'when size is smaller than max size' do
|
15
|
+
let(:column) { {:name=>"col_char", :type=>"varchar(18)", :default=>nil} }
|
16
|
+
it do
|
17
|
+
expect(subject).to eq(' "col_char" varchar(18) DEFAULT NULL')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when size exceeds varchar max size' do
|
22
|
+
let(:column) { {:name=>"col_char", :type=>"varchar(1000000000)", :default=>nil} }
|
23
|
+
it do
|
24
|
+
expect(subject).to eq(' "col_char" varchar(65535) DEFAULT NULL')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when size is max size' do
|
29
|
+
let(:column) { {:name=>"col_char", :type=>"varchar(max)", :default=>nil} }
|
30
|
+
it do
|
31
|
+
expect(subject).to eq(' "col_char" varchar(max) DEFAULT NULL')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flydata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -343,6 +343,15 @@ files:
|
|
343
343
|
- lib/flydata/credentials.rb
|
344
344
|
- lib/flydata/cron.rb
|
345
345
|
- lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb
|
346
|
+
- lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
|
347
|
+
- lib/flydata/fluent-plugins/mysql/binlog_position.rb
|
348
|
+
- lib/flydata/fluent-plugins/mysql/binlog_query_dispatcher.rb
|
349
|
+
- lib/flydata/fluent-plugins/mysql/binlog_query_handler.rb
|
350
|
+
- lib/flydata/fluent-plugins/mysql/binlog_record_dispatcher.rb
|
351
|
+
- lib/flydata/fluent-plugins/mysql/binlog_record_handler.rb
|
352
|
+
- lib/flydata/fluent-plugins/mysql/context.rb
|
353
|
+
- lib/flydata/fluent-plugins/mysql/dml_record_handler.rb
|
354
|
+
- lib/flydata/fluent-plugins/mysql/query_parser.rb
|
346
355
|
- lib/flydata/fluent-plugins/out_forward_ssl.rb
|
347
356
|
- lib/flydata/fluent-plugins/preference.rb
|
348
357
|
- lib/flydata/flydata_crontab.sh
|
@@ -364,6 +373,8 @@ files:
|
|
364
373
|
- spec/flydata/command/sender_spec.rb
|
365
374
|
- spec/flydata/command/sync_spec.rb
|
366
375
|
- spec/flydata/fluent-plugins/in_mysql_binlog_flydata_spec.rb
|
376
|
+
- spec/flydata/fluent-plugins/mysql/binlog_position_spec.rb
|
377
|
+
- spec/flydata/fluent-plugins/mysql/query_parser_spec.rb
|
367
378
|
- spec/flydata/heroku_spec.rb
|
368
379
|
- spec/flydata/table_def/mysql_table_def_spec.rb
|
369
380
|
- spec/flydata/table_def/mysqldump_test_foreign_key.dump
|
@@ -372,6 +383,7 @@ files:
|
|
372
383
|
- spec/flydata/table_def/mysqldump_test_table_enum.dump
|
373
384
|
- spec/flydata/table_def/mysqldump_test_table_multi_pk.dump
|
374
385
|
- spec/flydata/table_def/mysqldump_test_table_no_pk.dump
|
386
|
+
- spec/flydata/table_def/redshift_table_def_spec.rb
|
375
387
|
- spec/flydata/util/encryptor_spec.rb
|
376
388
|
- spec/flydata_spec.rb
|
377
389
|
- spec/spec_helper.rb
|
@@ -391,7 +403,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
391
403
|
version: '0'
|
392
404
|
segments:
|
393
405
|
- 0
|
394
|
-
hash:
|
406
|
+
hash: 1038365382785755967
|
395
407
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
396
408
|
none: false
|
397
409
|
requirements:
|
@@ -400,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
400
412
|
version: '0'
|
401
413
|
requirements: []
|
402
414
|
rubyforge_project:
|
403
|
-
rubygems_version: 1.8.
|
415
|
+
rubygems_version: 1.8.23
|
404
416
|
signing_key:
|
405
417
|
specification_version: 3
|
406
418
|
summary: FlyData CLI
|