flydata 0.7.13 → 0.7.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30343349c710d665850b71f57d39308b6db3ac9c
4
- data.tar.gz: 5c4ecdd659a4dc2e5a20bd12746bd2903315e71d
3
+ metadata.gz: 80a23a5417e480bb9b0b1847be172e3e75354d23
4
+ data.tar.gz: 6b29963fd37ac981f5a6ebda6485b82a6c1c6f39
5
5
  SHA512:
6
- metadata.gz: cffa5e91a09f5a7e9091dcd198db4e15d3de9c9666d753b888e06b1a8735de494371733353b1503f07a0dff41c8704ed29b8b143177d46649397f6580e7af548
7
- data.tar.gz: c13cb4a781ab2a263a9c88f52700a4d21e8ee11c1ab38b5c92620f2718846eae13c28394d9714e20ff58b6b81c6c8eb9611a764e00567541f33f83b91fdef0db
6
+ metadata.gz: 33e95be5a5ba2cb787f0d99655a1d83af447be3d3ee6122b24156c55de272e8c9eb73be1624e7ad26f45d6874234112d45149b63b42cab41c941a97c5bea5d95
7
+ data.tar.gz: 802b8a85a0c3ddc9009daa119b2842642a50a94718355b1787760d25e4970d53b5495bed832c9a82a0ca97bd5b569e3d179902fafd105d5f727a284a03dcf79e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.13
1
+ 0.7.14
@@ -33,6 +33,10 @@ module FlydataCore
33
33
  tables.collect{|tn| "'#{tn}'"}.join(',')
34
34
  end
35
35
 
36
+ def database_in_query(database)
37
+ "'#{database}'"
38
+ end
39
+
36
40
  def word_for_table_schema
37
41
  "schema"
38
42
  end
@@ -55,6 +59,7 @@ module FlydataCore
55
59
  # COMPATIBILITY_ERROR_CLASS = MysqlCompatibilityError
56
60
 
57
61
  def create_query(option = @option)
62
+ return nil if option[:tables].empty?
58
63
  self.class::TABLE_EXISTENCE_CHECK_QUERY_TMPLT % schema_and_table_in_query(option)
59
64
  end
60
65
 
@@ -83,6 +88,7 @@ module FlydataCore
83
88
 
84
89
  def check_result(result, option = @option)
85
90
  table_schema, missing_pk_tables = get_schema_and_tables(result)
91
+
86
92
  unless missing_pk_tables.empty?
87
93
  raise self.class::COMPATIBILITY_ERROR_CLASS,
88
94
  "Primary key is required for tables to sync. " +
@@ -34,9 +34,39 @@ module ErrorCode
34
34
  BREAKING_ALTER_TABLE_ERROR = 10010
35
35
  BREAKING_INFORMATION_SCHEMA_ERROR = 10011
36
36
  BREAKING_TABLE_DDL_ERROR = 10012
37
+ UNSUPPORTED_COLUMN_TYPE_ERROR = 10013
38
+ NO_PRIMARY_KEY_ERROR = 10014
37
39
  INTERNAL_ERROR = 1200
38
40
  end
39
41
 
42
+ module ErrorCode
43
+ # Convert an error reason to an error hash
44
+ # ex. {"err_code" => 10003, "Table does not exist"}
45
+ #
46
+ # Use this to convert an error message from an old agent to the new error hash
47
+ def self.err_reason_to_error(err_reason)
48
+ {"err_code" => lookup_err_code(err_reason), "err_reason" => err_reason}
49
+ end
50
+
51
+ def self.lookup_err_code(err_reason)
52
+ case err_reason
53
+ when /^no primary key defined/i
54
+ FlydataCore::ErrorCode::NO_PRIMARY_KEY_ERROR
55
+ when /^table does not exist in the MySQL database/i
56
+ FlydataCore::ErrorCode::TABLE_MISSING_ERROR
57
+ when /^GEOMETRY type/
58
+ FlydataCore::ErrorCode::UNSUPPORTED_COLUMN_TYPE_ERROR
59
+ when /^Newly registered table/
60
+ # The current agent doesn't send this error. Must be an old deprecated
61
+ # error.
62
+ FlydataCore::ErrorCode::INTERNAL_ERROR
63
+ else
64
+ # shouldn't come here
65
+ FlydataCore::ErrorCode::INTERNAL_ERROR
66
+ end
67
+ end
68
+ end
69
+
40
70
  # Error Level
41
71
  # 0 Emergency: system is unusable
42
72
  # 1 Alert: action must be taken immediately
@@ -124,6 +124,11 @@ module FlydataCore
124
124
  log_common(:debug, message, log_params, opt)
125
125
  end
126
126
 
127
+ def log_debug_with_backtrace(message, log_params = {}, options = {})
128
+ opt = { depth_offset: 1}.merge(options)
129
+ log_common(:debug, message, log_params, opt.merge(backtrace: true))
130
+ end
131
+
127
132
  def log_info(message, log_params = {}, options = {})
128
133
  opt = { depth_offset: 1}.merge(options)
129
134
  log_common(:info, message, log_params, opt)
@@ -134,6 +139,11 @@ module FlydataCore
134
139
  log_common(:warn, message, log_params, opt)
135
140
  end
136
141
 
142
+ def log_warn_with_backtrace(message, log_params = {}, options = {})
143
+ opt = { depth_offset: 1}.merge(options)
144
+ log_common(:warn, message, log_params, opt.merge(backtrace: true))
145
+ end
146
+
137
147
  def log_error(message, log_params = {}, options = {})
138
148
  opt = { depth_offset: 1}.merge(options)
139
149
  log_common(:error, message, log_params, opt)
@@ -145,7 +155,9 @@ module FlydataCore
145
155
  end
146
156
 
147
157
  def get_logger(options = {})
148
- options[:logger] || logger || log_context_logger || $log
158
+ ret = options[:logger] || logger || log_context_logger
159
+ ret = Rails.logger if ret.nil? && defined?(Rails) && Rails.logger
160
+ ret || $log
149
161
  end
150
162
 
151
163
  def build_log_message(level, raw_message, log_params = {}, options = {})
@@ -209,8 +209,8 @@ module FlydataCore
209
209
  include FlydataCore::CompatibilityCheck::TableExistenceCheck
210
210
  TABLE_EXISTENCE_CHECK_QUERY_TMPLT = <<EOT
211
211
  SELECT
212
- t.table_schema,
213
- t.table_name
212
+ t.table_schema as table_schema,
213
+ t.table_name as table_name
214
214
  FROM
215
215
  information_schema.tables t
216
216
  WHERE
@@ -243,16 +243,21 @@ EOT
243
243
  end
244
244
 
245
245
  class TableTypeChecker < MysqlCompatibilityChecker
246
- SELECT_TABLE_INFO_TMPLT =
247
- "SELECT table_name, table_type, engine " +
248
- "FROM information_schema.tables " +
249
- "WHERE table_schema = '%s' and table_name in (%s)"
246
+ SELECT_TABLE_INFO_TMPLT = <<EOT
247
+ SELECT
248
+ table_name as table_name,
249
+ table_type as table_type,
250
+ engine as engine
251
+ FROM information_schema.tables
252
+ WHERE table_schema = '%s' and table_name in (%s)
253
+ EOT
250
254
 
251
255
  UNSUPPORTED_ENGINES = %w(MEMORY BLACKHOLE)
252
256
 
253
257
  # option[:client] : Mysql2::Client object
254
258
  # option[:tables] : target table list
255
259
  def create_query(option = @option)
260
+ return nil if option[:tables].empty?
256
261
  SELECT_TABLE_INFO_TMPLT % [
257
262
  Mysql2::Client.escape(option[:database]),
258
263
  option[:tables].collect{|t| "'#{Mysql2::Client.escape(t)}'"}.join(", ")
@@ -277,8 +282,8 @@ EOT
277
282
  include FlydataCore::CompatibilityCheck::PrimaryKeyCheck
278
283
  PK_CHECK_QUERY_TMPLT = <<EOT
279
284
  SELECT
280
- t.table_schema,
281
- t.table_name,
285
+ t.table_schema as table_schema,
286
+ t.table_name as table_name,
282
287
  SUM(IF(tc.constraint_type='PRIMARY KEY' AND col.is_nullable='NO', 1, 0)) as num_pk,
283
288
  SUM(IF(tc.constraint_type='UNIQUE' AND col.is_nullable='NO', 1, 0)) as num_uk
284
289
  FROM
@@ -303,9 +308,9 @@ EOT
303
308
  include FlydataCore::CompatibilityCheck::PkOverrideCheck
304
309
  PK_OVERRIDE_QUERY_TMPLT = <<EOT
305
310
  SELECT
306
- t.table_schema,
307
- t.table_name,
308
- col.column_name
311
+ t.table_schema as table_schema,
312
+ t.table_name as table_name,
313
+ col.column_name as column_name
309
314
  FROM
310
315
  (select * from information_schema.tables where table_schema = %{schema_name} AND table_name in (%{table_names})) t
311
316
  LEFT JOIN
@@ -2,7 +2,7 @@ module FlydataCore
2
2
  module Mysql
3
3
  module Ssl
4
4
  # ssl cipher list not including DH algorithm
5
- NON_DH_SSL_CIPHER = "AES256-GCM-SHA384:AES256-SHA:AES256-SHA256:CAMELLIA256-SHA:DES-CBC3-SHA:PSK-3DES-EDE-CBC-SHA:PSK-AES256-CBC-SHA:SRP-DSS-3DES-EDE-CBC-SHA:SRP-DSS-AES-128-CBC-SHA:SRP-DSS-AES-256-CBC-SHA:SRP-RSA-3DES-EDE-CBC-SHA:SRP-RSA-AES-128-CBC-S:SRP-RSA-AES-256-CBC-SHA"
5
+ NON_DH_SSL_CIPHER = "DEFAULT:!DH"
6
6
  end
7
7
  end
8
8
  end
@@ -18,9 +18,9 @@ module FlydataCore
18
18
  end
19
19
 
20
20
  def schema_and_table_in_query(option = @option)
21
- schema = FlydataCore::Postgresql::QueryHelper.schema_as_value(option[:schema])
22
21
  {
23
- schema_name: schema,
22
+ database: database_in_query(option[:database]),
23
+ schema_name: FlydataCore::Postgresql::QueryHelper.schema_as_value(option[:schema]),
24
24
  table_names: table_names_in_query(option[:tables]),
25
25
  }
26
26
  end
@@ -59,6 +59,8 @@ SELECT
59
59
  FROM
60
60
  information_schema.tables
61
61
  WHERE
62
+ table_catalog = %{database}
63
+ AND
62
64
  table_schema = %{schema_name}
63
65
  AND
64
66
  table_name in (%{table_names})
@@ -71,17 +73,31 @@ EOT
71
73
  include FlydataCore::CompatibilityCheck::PrimaryKeyCheck
72
74
  PK_CHECK_QUERY_TMPLT = <<EOT
73
75
  SELECT
74
- t.table_schema,
75
- t.table_name
76
+ c.table_schema,
77
+ c.table_name
76
78
  FROM
77
- (select * from information_schema.tables where table_schema = %{schema_name} AND table_name in (%{table_names})) t
78
- LEFT OUTER JOIN
79
- (select * from information_schema.table_constraints where table_schema = %{schema_name} AND table_name in (%{table_names})) tc
80
- USING (table_schema, table_name)
79
+ pg_index i
80
+ JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)
81
+ RIGHT JOIN
82
+ (SELECT
83
+ (table_schema ||'.'|| table_name)::regclass AS regid,
84
+ *
85
+ FROM information_schema.columns
86
+ WHERE
87
+ table_catalog = %{database}
88
+ AND table_schema = %{schema_name}
89
+ AND table_name IN (%{table_names})
90
+ ) c
91
+ ON i.indrelid = c.regid AND a.attname = c.column_name
92
+ WHERE
93
+ c.table_catalog = %{database}
94
+ AND c.table_schema = %{schema_name}
95
+ AND c.table_name IN (%{table_names})
81
96
  GROUP BY
82
- t.table_schema, t.table_name
97
+ c.table_schema, c.table_name
83
98
  HAVING
84
- SUM(CASE WHEN tc.constraint_type='PRIMARY KEY' THEN 1 ELSE 0 END) = 0;
99
+ SUM(CASE WHEN i.indisprimary='t' THEN 1 ELSE 0 END) = 0 AND
100
+ SUM(CASE WHEN i.indisunique='t' THEN 1 ELSE 0 END) = 0;
85
101
  EOT
86
102
  end
87
103
 
@@ -93,10 +109,10 @@ SELECT
93
109
  t.table_name,
94
110
  col.column_name
95
111
  FROM
96
- (select * from information_schema.tables where table_schema = %{schema_name} AND table_name in (%{table_names})) t
112
+ (select * from information_schema.tables where table_catalog = %{database} AND table_schema = %{schema_name} AND table_name in (%{table_names})) t
97
113
  LEFT JOIN
98
- (select * from information_schema.columns where table_schema = %{schema_name} AND table_name in (%{table_names})) col
99
- ON t.table_schema = col.table_schema AND t.table_name = col.table_name
114
+ (select * from information_schema.columns where table_catalog = %{database} AND table_schema = %{schema_name} AND table_name in (%{table_names})) col
115
+ ON t.table_catalog = col.table_catalog AND t.table_schema = col.table_schema AND t.table_name = col.table_name
100
116
  ORDER BY
101
117
  t.table_name;
102
118
  EOT
@@ -49,6 +49,7 @@ class MysqlTableDef < Base
49
49
  'float' => {type: 'float4'},
50
50
  'int' => {type: 'int4', def_width: '11'},
51
51
  'integer' => {type: 'int4', def_width: '11'},
52
+ 'json' => {type: 'json'},
52
53
  'longblob' => {type: 'varbinary(4294967295)'},
53
54
  'longtext' => {type: 'text'},
54
55
  'mediumblob' => {type: 'varbinary(16777215)'},
@@ -33,6 +33,7 @@ class RedshiftTableDef
33
33
  'int4 unsigned' => {type: 'int8', unsigned: true, default_value: '0'},
34
34
  'int8' => {type: 'int8', default_value: '0'},
35
35
  'int8 unsigned' => {type: 'numeric(20,0)', unsigned: true, default_value: '0'},
36
+ 'json' => {type: 'varchar(max)', default_value: ''},
36
37
  'money' => {type: 'numeric', use_params: true, max_size: [38,37], default_value: '0'},
37
38
  'numeric' => {type: 'numeric', use_params: true, default_params: [18,8], max_size: [38,37], default_value: '0'},
38
39
  'numeric unsigned' => {type: 'numeric', use_params: true, default_params: [18,8], max_size: [38,37], default_value: '0'},
@@ -87,8 +87,8 @@ module FlydataCore
87
87
  subject { subject_object.create_query }
88
88
  it { is_expected.to eq <<EOT
89
89
  SELECT
90
- t.table_schema,
91
- t.table_name
90
+ t.table_schema as table_schema,
91
+ t.table_name as table_name
92
92
  FROM
93
93
  information_schema.tables t
94
94
  WHERE
@@ -99,6 +99,13 @@ UNION
99
99
  SELECT 'test_db', '';
100
100
  EOT
101
101
  }
102
+
103
+ context 'when tables is empty' do
104
+ before do
105
+ option[:tables] = []
106
+ end
107
+ it { is_expected.to be_nil }
108
+ end
102
109
  end
103
110
 
104
111
  describe '#check_reesult' do
@@ -137,8 +144,8 @@ EOT
137
144
  subject { subject_object.create_query }
138
145
  it { is_expected.to eq <<EOT
139
146
  SELECT
140
- t.table_schema,
141
- t.table_name,
147
+ t.table_schema as table_schema,
148
+ t.table_name as table_name,
142
149
  SUM(IF(tc.constraint_type='PRIMARY KEY' AND col.is_nullable='NO', 1, 0)) as num_pk,
143
150
  SUM(IF(tc.constraint_type='UNIQUE' AND col.is_nullable='NO', 1, 0)) as num_uk
144
151
  FROM
@@ -167,8 +174,8 @@ EOT
167
174
  end
168
175
  it { is_expected.to eq <<EOT
169
176
  SELECT
170
- t.table_schema,
171
- t.table_name,
177
+ t.table_schema as table_schema,
178
+ t.table_name as table_name,
172
179
  SUM(IF(tc.constraint_type='PRIMARY KEY' AND col.is_nullable='NO', 1, 0)) as num_pk,
173
180
  SUM(IF(tc.constraint_type='UNIQUE' AND col.is_nullable='NO', 1, 0)) as num_uk
174
181
  FROM
@@ -243,9 +250,9 @@ EOT
243
250
  end
244
251
  it { is_expected.to eq <<EOT
245
252
  SELECT
246
- t.table_schema,
247
- t.table_name,
248
- col.column_name
253
+ t.table_schema as table_schema,
254
+ t.table_name as table_name,
255
+ col.column_name as column_name
249
256
  FROM
250
257
  (select * from information_schema.tables where table_schema = 'test_db' AND table_name in ('table_1','table_2')) t
251
258
  LEFT JOIN
@@ -54,6 +54,8 @@ SELECT
54
54
  FROM
55
55
  information_schema.tables
56
56
  WHERE
57
+ table_catalog = 'test_db'
58
+ AND
57
59
  table_schema = (select current_schema)
58
60
  AND
59
61
  table_name in ('table_1','table_2','table_3')
@@ -71,6 +73,8 @@ SELECT
71
73
  FROM
72
74
  information_schema.tables
73
75
  WHERE
76
+ table_catalog = 'test_db'
77
+ AND
74
78
  table_schema = 'test_schema'
75
79
  AND
76
80
  table_name in ('table_1','table_2','table_3')
@@ -120,17 +124,31 @@ EOT
120
124
  context 'when schema is not set' do
121
125
  it { is_expected.to eq <<EOT
122
126
  SELECT
123
- t.table_schema,
124
- t.table_name
127
+ c.table_schema,
128
+ c.table_name
125
129
  FROM
126
- (select * from information_schema.tables where table_schema = (select current_schema) AND table_name in ('table_1','table_2','table_3')) t
127
- LEFT OUTER JOIN
128
- (select * from information_schema.table_constraints where table_schema = (select current_schema) AND table_name in ('table_1','table_2','table_3')) tc
129
- USING (table_schema, table_name)
130
+ pg_index i
131
+ JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)
132
+ RIGHT JOIN
133
+ (SELECT
134
+ (table_schema ||'.'|| table_name)::regclass AS regid,
135
+ *
136
+ FROM information_schema.columns
137
+ WHERE
138
+ table_catalog = 'test_db'
139
+ AND table_schema = (select current_schema)
140
+ AND table_name IN ('table_1','table_2','table_3')
141
+ ) c
142
+ ON i.indrelid = c.regid AND a.attname = c.column_name
143
+ WHERE
144
+ c.table_catalog = 'test_db'
145
+ AND c.table_schema = (select current_schema)
146
+ AND c.table_name IN ('table_1','table_2','table_3')
130
147
  GROUP BY
131
- t.table_schema, t.table_name
148
+ c.table_schema, c.table_name
132
149
  HAVING
133
- SUM(CASE WHEN tc.constraint_type='PRIMARY KEY' THEN 1 ELSE 0 END) = 0;
150
+ SUM(CASE WHEN i.indisprimary='t' THEN 1 ELSE 0 END) = 0 AND
151
+ SUM(CASE WHEN i.indisunique='t' THEN 1 ELSE 0 END) = 0;
134
152
  EOT
135
153
  }
136
154
  end
@@ -139,17 +157,31 @@ EOT
139
157
  before { option.merge!(schema: 'test_schema') }
140
158
  it { is_expected.to eq <<EOT
141
159
  SELECT
142
- t.table_schema,
143
- t.table_name
160
+ c.table_schema,
161
+ c.table_name
144
162
  FROM
145
- (select * from information_schema.tables where table_schema = 'test_schema' AND table_name in ('table_1','table_2','table_3')) t
146
- LEFT OUTER JOIN
147
- (select * from information_schema.table_constraints where table_schema = 'test_schema' AND table_name in ('table_1','table_2','table_3')) tc
148
- USING (table_schema, table_name)
163
+ pg_index i
164
+ JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)
165
+ RIGHT JOIN
166
+ (SELECT
167
+ (table_schema ||'.'|| table_name)::regclass AS regid,
168
+ *
169
+ FROM information_schema.columns
170
+ WHERE
171
+ table_catalog = 'test_db'
172
+ AND table_schema = 'test_schema'
173
+ AND table_name IN ('table_1','table_2','table_3')
174
+ ) c
175
+ ON i.indrelid = c.regid AND a.attname = c.column_name
176
+ WHERE
177
+ c.table_catalog = 'test_db'
178
+ AND c.table_schema = 'test_schema'
179
+ AND c.table_name IN ('table_1','table_2','table_3')
149
180
  GROUP BY
150
- t.table_schema, t.table_name
181
+ c.table_schema, c.table_name
151
182
  HAVING
152
- SUM(CASE WHEN tc.constraint_type='PRIMARY KEY' THEN 1 ELSE 0 END) = 0;
183
+ SUM(CASE WHEN i.indisprimary='t' THEN 1 ELSE 0 END) = 0 AND
184
+ SUM(CASE WHEN i.indisunique='t' THEN 1 ELSE 0 END) = 0;
153
185
  EOT
154
186
  }
155
187
  end
@@ -202,10 +234,10 @@ SELECT
202
234
  t.table_name,
203
235
  col.column_name
204
236
  FROM
205
- (select * from information_schema.tables where table_schema = (select current_schema) AND table_name in ('table_1','table_2')) t
237
+ (select * from information_schema.tables where table_catalog = 'test_db' AND table_schema = (select current_schema) AND table_name in ('table_1','table_2')) t
206
238
  LEFT JOIN
207
- (select * from information_schema.columns where table_schema = (select current_schema) AND table_name in ('table_1','table_2')) col
208
- ON t.table_schema = col.table_schema AND t.table_name = col.table_name
239
+ (select * from information_schema.columns where table_catalog = 'test_db' AND table_schema = (select current_schema) AND table_name in ('table_1','table_2')) col
240
+ ON t.table_catalog = col.table_catalog AND t.table_schema = col.table_schema AND t.table_name = col.table_name
209
241
  ORDER BY
210
242
  t.table_name;
211
243
  EOT
@@ -44,6 +44,7 @@ describe MysqlTableDef do
44
44
  {:column=>"col_float_4_2", :type=>"float4(4,2)", :default=>nil},
45
45
  {:column=>"col_int", :type=>"int4(11)", :default=>nil},
46
46
  {:column=>"col_int_6", :type=>"int4(6)", :default=>nil},
47
+ {:column=>"col_json", :type=>"json", :default=>nil},
47
48
  {:column=>"col_longblob", :type=>"varbinary(4294967295)"},
48
49
  {:column=>"col_longtext", :type=>"text"},
49
50
  {:column=>"col_mediumblob", :type=>"varbinary(16777215)"},
@@ -88,6 +89,7 @@ describe MysqlTableDef do
88
89
  `col_float_4_2` float(4,2) DEFAULT NULL,
89
90
  `col_int` int(11) DEFAULT NULL,
90
91
  `col_int_6` int(6) DEFAULT NULL,
92
+ `col_json` json DEFAULT NULL,
91
93
  `col_longblob` longblob,
92
94
  `col_longtext` longtext,
93
95
  `col_mediumblob` mediumblob,
@@ -67,6 +67,7 @@ CREATE TABLE IF NOT EXISTS "test_table_all" (
67
67
  "col_float_4_2" float4 DEFAULT NULL,
68
68
  "col_int" int4 DEFAULT NULL,
69
69
  "col_int_6" int4 DEFAULT NULL,
70
+ "col_json" varchar(max) DEFAULT NULL,
70
71
  "col_longblob" varchar(65535),
71
72
  "col_longtext" varchar(max),
72
73
  "col_mediumblob" varchar(65535),
@@ -101,6 +102,7 @@ CREATE TABLE "test_table_all" (
101
102
  "col_float_4_2" float4 DEFAULT NULL,
102
103
  "col_int" int4 DEFAULT NULL,
103
104
  "col_int_6" int4 DEFAULT NULL,
105
+ "col_json" varchar(max) DEFAULT NULL,
104
106
  "col_longblob" varchar(65535),
105
107
  "col_longtext" varchar(max),
106
108
  "col_mediumblob" varchar(65535),
@@ -135,23 +137,24 @@ INSERT INTO "flydata_ctl_columns" (table_name, column_name, src_data_type, ordin
135
137
  ('test_table_all', 'col_float_4_2', 'float4(4,2)', 11),
136
138
  ('test_table_all', 'col_int', 'int4(11)', 12),
137
139
  ('test_table_all', 'col_int_6', 'int4(6)', 13),
138
- ('test_table_all', 'col_longblob', 'varbinary(4294967295)', 14),
139
- ('test_table_all', 'col_longtext', 'text', 15),
140
- ('test_table_all', 'col_mediumblob', 'varbinary(16777215)', 16),
141
- ('test_table_all', 'col_mediumint', 'int3(9)', 17),
142
- ('test_table_all', 'col_mediumtext', 'text', 18),
143
- ('test_table_all', 'col_smallint', 'int2(6)', 19),
144
- ('test_table_all', 'col_text', 'text', 20),
145
- ('test_table_all', 'col_time', 'time', 21),
146
- ('test_table_all', 'col_timestamp', 'datetime', 22),
147
- ('test_table_all', 'col_tinyblob', 'varbinary(255)', 23),
148
- ('test_table_all', 'col_tinyint', 'int1(4)', 24),
149
- ('test_table_all', 'col_tinytext', 'text', 25),
150
- ('test_table_all', 'col_varbinary', 'varbinary(512)', 26),
151
- ('test_table_all', 'col_varchar', 'varchar(372)', 27),
152
- ('test_table_all', 'col_year', 'year', 28),
153
- ('test_table_all', 'col_year_4', 'year(4)', 29),
154
- ('test_table_all', 'col_year_2', 'year(2)', 30);
140
+ ('test_table_all', 'col_json', 'json', 14),
141
+ ('test_table_all', 'col_longblob', 'varbinary(4294967295)', 15),
142
+ ('test_table_all', 'col_longtext', 'text', 16),
143
+ ('test_table_all', 'col_mediumblob', 'varbinary(16777215)', 17),
144
+ ('test_table_all', 'col_mediumint', 'int3(9)', 18),
145
+ ('test_table_all', 'col_mediumtext', 'text', 19),
146
+ ('test_table_all', 'col_smallint', 'int2(6)', 20),
147
+ ('test_table_all', 'col_text', 'text', 21),
148
+ ('test_table_all', 'col_time', 'time', 22),
149
+ ('test_table_all', 'col_timestamp', 'datetime', 23),
150
+ ('test_table_all', 'col_tinyblob', 'varbinary(255)', 24),
151
+ ('test_table_all', 'col_tinyint', 'int1(4)', 25),
152
+ ('test_table_all', 'col_tinytext', 'text', 26),
153
+ ('test_table_all', 'col_varbinary', 'varbinary(512)', 27),
154
+ ('test_table_all', 'col_varchar', 'varchar(372)', 28),
155
+ ('test_table_all', 'col_year', 'year', 29),
156
+ ('test_table_all', 'col_year_4', 'year(4)', 30),
157
+ ('test_table_all', 'col_year_2', 'year(2)', 31);
155
158
  DELETE FROM "flydata_ctl_tables" WHERE table_name = 'test_table_all';
156
159
  INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
157
160
  ('test_table_all', 'cs', 'UTF_8'),
@@ -170,6 +173,7 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
170
173
  `col_float_4_2` float(4,2) DEFAULT NULL,
171
174
  `col_int` int(11) DEFAULT NULL,
172
175
  `col_int_6` int(6) DEFAULT NULL,
176
+ `col_json` json DEFAULT NULL,
173
177
  `col_longblob` longblob,
174
178
  `col_longtext` longtext,
175
179
  `col_mediumblob` mediumblob,
@@ -36,6 +36,7 @@ CREATE TABLE `test_table_all` (
36
36
  `col_float_4_2` float(4,2) DEFAULT NULL,
37
37
  `col_int` int(11) DEFAULT NULL,
38
38
  `col_int_6` int(6) DEFAULT NULL,
39
+ `col_json` json DEFAULT NULL,
39
40
  `col_longblob` longblob,
40
41
  `col_longtext` longtext,
41
42
  `col_mediumblob` mediumblob,
@@ -731,6 +731,21 @@ EOT
731
731
  it_behaves_like *examples
732
732
  end
733
733
  end
734
+
735
+ context 'with json column def' do
736
+ before do
737
+ column[:column] = "value_json"
738
+ column[:type] = "json"
739
+ end
740
+ let(:type_sql) { %Q|"value_json" varchar(max)| }
741
+ let(:not_null_default_sql) { " DEFAULT '{}'" }
742
+
743
+ context 'when default_value is normal' do
744
+ let(:default_value) { "{}" }
745
+ let(:default_value_sql) { "'{}'" }
746
+ it_behaves_like *examples
747
+ end
748
+ end
734
749
  end
735
750
 
736
751
  context 'for create table' do
data/flydata.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "flydata"
8
- s.version = "0.7.13"
8
+ s.version = "0.7.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Koichi Fujikawa", "Masashi Miyazaki", "Matthew Luu", "Mak Inada", "Sriram NS"]
12
- s.date = "2016-11-18"
12
+ s.date = "2016-12-02"
13
13
  s.description = "FlyData Agent"
14
14
  s.email = "sysadmin@flydata.com"
15
15
  s.executables = ["fdredshift", "flydata", "serverinfo", "split_sync_ddl.rb"]
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.7.13
4
+ version: 0.7.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Fujikawa
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-11-18 00:00:00.000000000 Z
15
+ date: 2016-12-02 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rest-client