flydata 0.1.4 → 0.1.5

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
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.1.4"
8
+ s.version = "0.1.5"
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"]
12
- s.date = "2014-05-15"
12
+ s.date = "2014-05-17"
13
13
  s.description = "FlyData Command Line Interface"
14
14
  s.email = "sysadmin@flydata.co"
15
15
  s.executables = ["fdmysqldump", "flydata"]
@@ -73,6 +73,7 @@ Gem::Specification.new do |s|
73
73
  "spec/flydata/fluent-plugins/in_mysql_binlog_flydata_spec.rb",
74
74
  "spec/flydata/heroku_spec.rb",
75
75
  "spec/flydata/table_def/mysql_table_def_spec.rb",
76
+ "spec/flydata/table_def/mysqldump_test_foreign_key.dump",
76
77
  "spec/flydata/table_def/mysqldump_test_table_all.dump",
77
78
  "spec/flydata/table_def/mysqldump_test_table_column_comment.dump",
78
79
  "spec/flydata/table_def/mysqldump_test_table_enum.dump",
@@ -929,10 +929,12 @@ EOT
929
929
  index += 1
930
930
  if chars.start_with?("'")
931
931
  # single item (not last item)
932
- if chars.end_with?("'") and !last_char_escaped?(chars)
932
+ # size check added below otherwise end_with? matches the single quote which was also used by start_with?
933
+ if chars.size > 1 and chars.end_with?("'") and !last_char_escaped?(chars)
933
934
  @values << replace_escape_char(chars[1..-2])
934
935
  # single item (last item)
935
- elsif chars.end_with?("')") and !last_char_escaped?(chars[0..-2])
936
+ # size check added below otherwise end_with? matches the single quote which was also used by start_with?
937
+ elsif chars.size > 2 and chars.end_with?("')") and !last_char_escaped?(chars[0..-2])
936
938
  @values << replace_escape_char(chars[1..-3])
937
939
  @values_set << @values
938
940
  @values = []
@@ -1162,6 +1162,55 @@ EOT
1162
1162
  expect(subject).to eq([['1',"D:\\download\\",'2014-04-15 13:49:14']])
1163
1163
  end
1164
1164
  end
1165
+
1166
+ context 'when comma is the first character of a string' do
1167
+ let(:target_line) { "INSERT INTO `test_table` VALUES (1,',9','2014-04-15 13:49:14');" }
1168
+ it 'should parse the string correctly' do
1169
+ expect(subject).to eq([['1',',9','2014-04-15 13:49:14']])
1170
+ end
1171
+ end
1172
+
1173
+ context 'when comma is the last character of a string' do
1174
+ let(:target_line) { "INSERT INTO `test_table` VALUES (1,'9,','2014-04-15 13:49:14');" }
1175
+ it 'should parse the string correctly' do
1176
+ expect(subject).to eq([['1','9,','2014-04-15 13:49:14']])
1177
+ end
1178
+ end
1179
+
1180
+ context 'when a string consists of a comma' do
1181
+ let(:target_line) { "INSERT INTO `test_table` VALUES (1,',','2014-04-15 13:49:14');" }
1182
+ it 'should parse the string correctly' do
1183
+ expect(subject).to eq([['1',',','2014-04-15 13:49:14']])
1184
+ end
1185
+ end
1186
+
1187
+ context 'when two commas are given as a string' do
1188
+ let(:target_line) { "INSERT INTO `test_table` VALUES (1,',,','2014-04-15 13:49:14');" }
1189
+ it 'should parse the string correctly' do
1190
+ expect(subject).to eq([['1',',,','2014-04-15 13:49:14']])
1191
+ end
1192
+ end
1193
+
1194
+ context 'when an empty string value is given' do
1195
+ let(:target_line) { "INSERT INTO `test_table` VALUES (1,'','2014-04-15 13:49:14');" }
1196
+ it 'should parse the string correctly' do
1197
+ expect(subject).to eq([['1','','2014-04-15 13:49:14']])
1198
+ end
1199
+ end
1200
+
1201
+ context 'when a value consists of a comma followed by closing bracket' do
1202
+ let(:target_line) { "INSERT INTO `test_table` VALUES (1,'),ksd','2014-04-15 13:49:14');" }
1203
+ it 'should parse the string correctly' do
1204
+ expect(subject).to eq([['1','),ksd','2014-04-15 13:49:14']])
1205
+ end
1206
+ end
1207
+
1208
+ context 'when there is a white space before the closing bracket' do
1209
+ let(:target_line) { "INSERT INTO `test_table` VALUES (1,'aa','2014-04-15 13:49:14' );" }
1210
+ it 'should fail to parse. This is intentional for performance reason' do
1211
+ expect{subject}.to raise_error
1212
+ end
1213
+ end
1165
1214
  end
1166
1215
  end
1167
1216
  end
@@ -0,0 +1,48 @@
1
+ -- MySQL dump 10.13 Distrib 5.1.73, for redhat-linux-gnu (x86_64)
2
+ --
3
+ -- Host: strenua.flydata.co Database: create_table_examples
4
+ -- ------------------------------------------------------
5
+ -- Server version 5.6.17-1+deb.sury.org~precise+1-log
6
+
7
+ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8
+ /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9
+ /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10
+ /*!40101 SET NAMES utf8 */;
11
+ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
12
+ /*!40103 SET TIME_ZONE='+00:00' */;
13
+ /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
14
+ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
15
+ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
16
+ /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
17
+
18
+ --
19
+ -- Table structure for table `product_order`
20
+ --
21
+
22
+ DROP TABLE IF EXISTS `product_order`;
23
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
24
+ /*!40101 SET character_set_client = utf8 */;
25
+ CREATE TABLE `product_order` (
26
+ `no` int(11) NOT NULL AUTO_INCREMENT,
27
+ `product_category` int(11) NOT NULL,
28
+ `product_id` int(11) NOT NULL,
29
+ `customer_id` int(11) NOT NULL,
30
+ PRIMARY KEY (`no`),
31
+ KEY `product_category` (`product_category`,`product_id`),
32
+ KEY `customer_id` (`customer_id`),
33
+ CONSTRAINT `product_order_ibfk_1` FOREIGN KEY (`product_category`, `product_id`) REFERENCES `product` (`category`, `id`) ON UPDATE CASCADE,
34
+ CONSTRAINT `product_order_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`)
35
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
36
+ /*!40101 SET character_set_client = @saved_cs_client */;
37
+ /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
38
+
39
+ /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
40
+ /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
41
+ /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
42
+ /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
43
+ /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
44
+ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
45
+ /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
46
+
47
+ -- Dump completed on 2014-05-15 19:47:48
48
+
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
4
+ version: 0.1.5
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-05-15 00:00:00.000000000 Z
12
+ date: 2014-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -366,6 +366,7 @@ files:
366
366
  - spec/flydata/fluent-plugins/in_mysql_binlog_flydata_spec.rb
367
367
  - spec/flydata/heroku_spec.rb
368
368
  - spec/flydata/table_def/mysql_table_def_spec.rb
369
+ - spec/flydata/table_def/mysqldump_test_foreign_key.dump
369
370
  - spec/flydata/table_def/mysqldump_test_table_all.dump
370
371
  - spec/flydata/table_def/mysqldump_test_table_column_comment.dump
371
372
  - spec/flydata/table_def/mysqldump_test_table_enum.dump
@@ -390,7 +391,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
390
391
  version: '0'
391
392
  segments:
392
393
  - 0
393
- hash: -913931267445812581
394
+ hash: 2175576432657099450
394
395
  required_rubygems_version: !ruby/object:Gem::Requirement
395
396
  none: false
396
397
  requirements: