embulk-output-sqlserver 0.7.10 → 0.7.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/build.gradle +1 -1
- data/classpath/{embulk-output-jdbc-0.7.10.jar → embulk-output-jdbc-0.7.11.jar} +0 -0
- data/classpath/{embulk-output-sqlserver-0.7.10.jar → embulk-output-sqlserver-0.7.11.jar} +0 -0
- data/src/main/java/org/embulk/output/SQLServerOutputPlugin.java +17 -8
- data/src/test/java/org/embulk/output/sqlserver/BasicTest.java +200 -0
- data/src/test/java/org/embulk/output/sqlserver/SQLServerTests.java +80 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/setup.sql +82 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test1.csv +4 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_expected.diff +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_insert.yml +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_insert_create_expected.csv +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_insert_direct.yml +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_insert_expected.csv +4 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge.csv +5 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge.yml +2 -0
- data/src/test/resources/{sqlserver/data/test6/test6.csv → org/embulk/output/sqlserver/test/expect/basic/test_merge_expected.csv} +6 -4
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge_keys.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge_rule.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge_rule_expected.csv +6 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_native_insert_direct.yml +3 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_replace.yml +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_replace_longname.yml +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_string_timestamp.csv +4 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_string_timestamp.yml +5 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_string_timestamp_expected.csv +4 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_truncate_insert.yml +2 -0
- data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_truncate_insert_expected.csv +3 -0
- metadata +27 -27
- data/src/test/java/org/embulk/output/sqlserver/PreciseTime.java +0 -48
- data/src/test/java/org/embulk/output/sqlserver/SQLServerOutputPluginTest.java +0 -923
- data/src/test/resources/sqlserver/data/test1/test1.csv +0 -3
- data/src/test/resources/sqlserver/data/test2/test2.csv +0 -2
- data/src/test/resources/sqlserver/data/test3/test3.csv +0 -2
- data/src/test/resources/sqlserver/data/test4/test4.csv +0 -2
- data/src/test/resources/sqlserver/data/test5/test5.csv +0 -2
- data/src/test/resources/sqlserver/yml/test-insert-direct.yml +0 -43
- data/src/test/resources/sqlserver/yml/test-insert.yml +0 -43
- data/src/test/resources/sqlserver/yml/test-jtds.yml +0 -43
- data/src/test/resources/sqlserver/yml/test-merge-keys.yml +0 -23
- data/src/test/resources/sqlserver/yml/test-merge-rule.yml +0 -22
- data/src/test/resources/sqlserver/yml/test-merge.yml +0 -21
- data/src/test/resources/sqlserver/yml/test-native-date.yml +0 -26
- data/src/test/resources/sqlserver/yml/test-native-decimal.yml +0 -25
- data/src/test/resources/sqlserver/yml/test-native-integer.yml +0 -24
- data/src/test/resources/sqlserver/yml/test-native-string.yml +0 -25
- data/src/test/resources/sqlserver/yml/test-native.yml +0 -44
- data/src/test/resources/sqlserver/yml/test-replace-long-name.yml +0 -43
- data/src/test/resources/sqlserver/yml/test-replace.yml +0 -43
- data/src/test/resources/sqlserver/yml/test-string-timestamp.yml +0 -46
- data/src/test/resources/sqlserver/yml/test-truncate-insert.yml +0 -43
@@ -0,0 +1,4 @@
|
|
1
|
+
ID:string,TINYINT_ITEM:long,SMALLINT_ITEM:long,INT_ITEM:long,BIGINT_ITEM:long,BIT_ITEM:boolean,DECIMAL_ITEM:string,NUMERIC_ITEM:string,SMALLMONEY_ITEM:string,MONEY_ITEM:string,REAL_ITEM:double,FLOAT_ITEM:double,CHAR_ITEM:string,VARCHAR_ITEM:string,TEXT_ITEM:string,NCHAR_ITEM:string,NVARCHAR_ITEM:string,NTEXT_ITEM:string,DATE_ITEM:timestamp,DATETIME_ITEM:timestamp,DATETIME2_ITEM:timestamp,DATETIME2_2_ITEM:timestamp,SMALLDATETIME_ITEM:timestamp,TIME_ITEM:timestamp,TIME_2_ITEM:timestamp
|
2
|
+
A001,0,1234,123456,12345678901,0,1.23,3.456,12.34,123.4567,0.1234567,0.12345678901234,a,b,c,A,B,C,2016-1-1 00:00:00.0 +0900,2017-1-1 1:2:3.123 +0900,2018-1-1 1:2:3.1234567 +0900,2019-1-1 1:2:3.12 +0900,2020-1-1 1:2:3.0 +0900,1970-01-01 3:4:5.1234567 +0900,1970-01-01 6:7:8.12 +0900
|
3
|
+
A002,255,-32768,-2147483648,-9223372036854775808,1,-9999999999.99,-99.999,-214748.3648,-922337203685477.5808,-9999000000,-999999999999000000,あい,あいうえ,あいうえお,かき,かきくけ,かきくけこ,2016-12-31 00:00:00.0 +0900,2017-12-31 23:59:59.997 +0900,2018-12-31 23:59:59.9999999 +0900,2019-12-31 23:59:59.99 +0900,2020-12-31 23:59:59.0 +0900,1970-01-01 23:59:59.9999999 +0900,1970-01-01 23:59:59.99 +0900
|
4
|
+
A003,,,,,,,,,,,,,,,,,,,,,,,,
|
@@ -0,0 +1,3 @@
|
|
1
|
+
A001,0,1234,123456,12345678901,0,1.23,3.456,12.34,123.4567,0.1234567,0.12345678901234,a,b,c,A,B,C,2015-12-31 15:00:00.0000000,2016-12-31 16:02:03.1230000,2017-12-31 16:02:03.1234560,2018-12-31 16:02:03.1200000,2019-12-31 16:02:03.0000000,1969-12-31 18:04:05.1234560,1969-12-31 21:07:08.1200000
|
2
|
+
A002,255,-32768,-2147483648,-9223372036854775808,1,-9999999999.99,-99.999,-214748.3648,-922337203685477.5808,-9999000000.0,-9.9999999999900006E+17,あい,あいうえ,あいうえお,かき,かきくけ,かきくけこ,2016-12-30 15:00:00.0000000,2017-12-31 14:59:59.9970000,2018-12-31 14:59:59.9999990,2019-12-31 14:59:59.9900000,2020-12-31 14:59:59.0000000,1970-01-01 14:59:59.9999990,1970-01-01 14:59:59.9900000
|
3
|
+
A003,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
|
data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_insert_expected.csv
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
9999,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
|
2
|
+
A001,0,1234,123456,12345678901,0,1.23,3.456,12.3400,123.4567,0.1234567,0.12345678901234,a ,b,c,A ,B,C,2015-12-31,2016-12-31 16:02:03.123,2017-12-31 16:02:03.1234560,2018-12-31 16:02:03.12,2019-12-31 16:02:00,18:04:05.1234560,21:07:08.12
|
3
|
+
A002,255,-32768,-2147483648,-9223372036854775808,1,-9999999999.99,-99.999,-214748.3648,-922337203685477.5808,-9.9989996E+9,-9.9999999999900006E+17,あい,あいうえ,あいうえお,かき ,かきくけ,かきくけこ,2016-12-30,2017-12-31 14:59:59.997,2018-12-31 14:59:59.9999990,2019-12-31 14:59:59.99,2020-12-31 15:00:00,14:59:59.9999990,14:59:59.99
|
4
|
+
A003,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
|
data/src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_string_timestamp.csv
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
ID:string,TINYINT_ITEM:long,SMALLINT_ITEM:long,INT_ITEM:long,BIGINT_ITEM:long,BIT_ITEM:boolean,DECIMAL_ITEM:string,NUMERIC_ITEM:string,SMALLMONEY_ITEM:string,MONEY_ITEM:string,REAL_ITEM:double,FLOAT_ITEM:double,CHAR_ITEM:string,VARCHAR_ITEM:string,TEXT_ITEM:string,NCHAR_ITEM:string,NVARCHAR_ITEM:string,NTEXT_ITEM:string,DATE_ITEM:timestamp,DATETIME_ITEM:timestamp,DATETIME2_ITEM:string,DATETIME2_2_ITEM:timestamp,SMALLDATETIME_ITEM:timestamp,TIME_ITEM:string,TIME_2_ITEM:timestamp
|
2
|
+
A001,0,1234,123456,12345678901,0,1.23,3.456,12.34,123.4567,0.1234567,0.12345678901234,a,b,c,A,B,C,2016-1-1 00:00:00.0 +0900,2017-1-1 1:2:3.123 +0900,2018/1/1 1:2:3.1234567,2019-1-1 1:2:3.12 +0900,2020-1-1 1:2:3.0 +0900,3:4:5.1234567,1970-01-01 6:7:8.12 +0900
|
3
|
+
A002,255,-32768,-2147483648,-9223372036854775808,1,-9999999999.99,-99.999,-214748.3648,-922337203685477.5808,-9999000000,-999999999999000000,あい,あいうえ,あいうえお,かき,かきくけ,かきくけこ,2016-12-31 00:00:00.0 +0900,2017-12-31 23:59:59.997 +0900,2018/12/31 23:59:59.9999999,2019-12-31 23:59:59.99 +0900,2020-12-31 23:59:59.0 +0900,23:59:59.9999999,1970-01-01 23:59:59.99 +0900
|
4
|
+
A003,,,,,,,,,,,,,,,,,,,,,,,,
|
@@ -0,0 +1,4 @@
|
|
1
|
+
9999,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
|
2
|
+
A001,0,1234,123456,12345678901,0,1.23,3.456,12.3400,123.4567,0.1234567,0.12345678901234,a ,b,c,A ,B,C,2015-12-31,2016-12-31 16:02:03.123,2018-01-01 01:02:03.1234567,2018-12-31 16:02:03.12,2019-12-31 16:02:00,03:04:05.1234567,21:07:08.12
|
3
|
+
A002,255,-32768,-2147483648,-9223372036854775808,1,-9999999999.99,-99.999,-214748.3648,-922337203685477.5808,-9.9989996E+9,-9.9999999999900006E+17,あい,あいうえ,あいうえお,かき ,かきくけ,かきくけこ,2016-12-30,2017-12-31 14:59:59.997,2018-12-31 23:59:59.9999999,2019-12-31 14:59:59.99,2020-12-31 15:00:00,23:59:59.9999999,14:59:59.99
|
4
|
+
A003,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
|
@@ -0,0 +1,3 @@
|
|
1
|
+
A001,0,1234,123456,12345678901,0,1.23,3.456,12.3400,123.4567,0.1234567,0.12345678901234,a ,b,c,A ,B,C,2015-12-31,2016-12-31 16:02:03.123,2017-12-31 16:02:03.1234560,2018-12-31 16:02:03.12,2019-12-31 16:02:00,18:04:05.1234560,21:07:08.12
|
2
|
+
A002,255,-32768,-2147483648,-9223372036854775808,1,-9999999999.99,-99.999,-214748.3648,-922337203685477.5808,-9.9989996E+9,-9.9999999999900006E+17,あい,あいうえ,あいうえお,かき ,かきくけ,かきくけこ,2016-12-30,2017-12-31 14:59:59.997,2018-12-31 14:59:59.9999990,2019-12-31 14:59:59.99,2020-12-31 15:00:00,14:59:59.9999990,14:59:59.99
|
3
|
+
A003,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-sqlserver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Inserts or updates records to a table.
|
14
14
|
email:
|
@@ -19,8 +19,8 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- README.md
|
21
21
|
- build.gradle
|
22
|
-
- classpath/embulk-output-jdbc-0.7.
|
23
|
-
- classpath/embulk-output-sqlserver-0.7.
|
22
|
+
- classpath/embulk-output-jdbc-0.7.11.jar
|
23
|
+
- classpath/embulk-output-sqlserver-0.7.11.jar
|
24
24
|
- classpath/jtds-1.3.1.jar
|
25
25
|
- lib/embulk/output/sqlserver.rb
|
26
26
|
- src/main/java/org/embulk/output/SQLServerOutputPlugin.java
|
@@ -35,29 +35,29 @@ files:
|
|
35
35
|
- src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
|
36
36
|
- src/main/java/org/embulk/output/sqlserver/setter/SQLServerColumnSetterFactory.java
|
37
37
|
- src/main/java/org/embulk/output/sqlserver/setter/SQLServerSqlTimeColumnSetter.java
|
38
|
-
- src/test/java/org/embulk/output/sqlserver/
|
39
|
-
- src/test/java/org/embulk/output/sqlserver/
|
40
|
-
- src/test/resources/sqlserver/
|
41
|
-
- src/test/resources/sqlserver/
|
42
|
-
- src/test/resources/sqlserver/
|
43
|
-
- src/test/resources/sqlserver/
|
44
|
-
- src/test/resources/sqlserver/
|
45
|
-
- src/test/resources/sqlserver/
|
46
|
-
- src/test/resources/sqlserver/
|
47
|
-
- src/test/resources/sqlserver/
|
48
|
-
- src/test/resources/sqlserver/
|
49
|
-
- src/test/resources/sqlserver/
|
50
|
-
- src/test/resources/sqlserver/
|
51
|
-
- src/test/resources/sqlserver/
|
52
|
-
- src/test/resources/sqlserver/
|
53
|
-
- src/test/resources/sqlserver/
|
54
|
-
- src/test/resources/sqlserver/
|
55
|
-
- src/test/resources/sqlserver/
|
56
|
-
- src/test/resources/sqlserver/
|
57
|
-
- src/test/resources/sqlserver/
|
58
|
-
- src/test/resources/sqlserver/
|
59
|
-
- src/test/resources/sqlserver/
|
60
|
-
- src/test/resources/sqlserver/
|
38
|
+
- src/test/java/org/embulk/output/sqlserver/BasicTest.java
|
39
|
+
- src/test/java/org/embulk/output/sqlserver/SQLServerTests.java
|
40
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/setup.sql
|
41
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test1.csv
|
42
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_expected.diff
|
43
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_insert.yml
|
44
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_insert_create_expected.csv
|
45
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_insert_direct.yml
|
46
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_insert_expected.csv
|
47
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge.csv
|
48
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge.yml
|
49
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge_expected.csv
|
50
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge_keys.yml
|
51
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge_rule.yml
|
52
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_merge_rule_expected.csv
|
53
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_native_insert_direct.yml
|
54
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_replace.yml
|
55
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_replace_longname.yml
|
56
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_string_timestamp.csv
|
57
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_string_timestamp.yml
|
58
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_string_timestamp_expected.csv
|
59
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_truncate_insert.yml
|
60
|
+
- src/test/resources/org/embulk/output/sqlserver/test/expect/basic/test_truncate_insert_expected.csv
|
61
61
|
homepage: https://github.com/embulk/embulk-output-jdbc
|
62
62
|
licenses:
|
63
63
|
- Apache 2.0
|
@@ -1,48 +0,0 @@
|
|
1
|
-
package org.embulk.output.sqlserver;
|
2
|
-
|
3
|
-
import java.sql.Time;
|
4
|
-
import java.sql.Timestamp;
|
5
|
-
|
6
|
-
public class PreciseTime extends Time
|
7
|
-
{
|
8
|
-
private final int nanos;
|
9
|
-
|
10
|
-
public PreciseTime(long time, int nanos)
|
11
|
-
{
|
12
|
-
super(time);
|
13
|
-
|
14
|
-
this.nanos = nanos;
|
15
|
-
}
|
16
|
-
|
17
|
-
public PreciseTime(Time time, int nanos)
|
18
|
-
{
|
19
|
-
this(time.getTime(), nanos);
|
20
|
-
}
|
21
|
-
|
22
|
-
public PreciseTime(Timestamp timestamp)
|
23
|
-
{
|
24
|
-
this(timestamp.getTime(), timestamp.getNanos());
|
25
|
-
}
|
26
|
-
|
27
|
-
public int getNanos()
|
28
|
-
{
|
29
|
-
return nanos;
|
30
|
-
}
|
31
|
-
|
32
|
-
@Override
|
33
|
-
public boolean equals(Object o)
|
34
|
-
{
|
35
|
-
if (!(o instanceof PreciseTime)) {
|
36
|
-
return false;
|
37
|
-
}
|
38
|
-
|
39
|
-
return toString().equals(o.toString());
|
40
|
-
}
|
41
|
-
|
42
|
-
@Override
|
43
|
-
public String toString()
|
44
|
-
{
|
45
|
-
return String.format("%s.%09d", super.toString(), nanos);
|
46
|
-
}
|
47
|
-
|
48
|
-
}
|
@@ -1,923 +0,0 @@
|
|
1
|
-
package org.embulk.output.sqlserver;
|
2
|
-
|
3
|
-
import org.embulk.output.AbstractJdbcOutputPluginTest;
|
4
|
-
import org.embulk.output.SQLServerOutputPlugin;
|
5
|
-
import org.embulk.spi.OutputPlugin;
|
6
|
-
import org.junit.Test;
|
7
|
-
|
8
|
-
import java.math.BigDecimal;
|
9
|
-
import java.sql.Connection;
|
10
|
-
import java.sql.DriverManager;
|
11
|
-
import java.sql.ResultSet;
|
12
|
-
import java.sql.SQLException;
|
13
|
-
import java.sql.Timestamp;
|
14
|
-
import java.text.DateFormat;
|
15
|
-
import java.text.ParseException;
|
16
|
-
import java.text.SimpleDateFormat;
|
17
|
-
import java.util.Date;
|
18
|
-
import java.util.Iterator;
|
19
|
-
import java.util.List;
|
20
|
-
|
21
|
-
import static java.util.Locale.ENGLISH;
|
22
|
-
import static org.junit.Assert.assertEquals;
|
23
|
-
|
24
|
-
|
25
|
-
public class SQLServerOutputPluginTest extends AbstractJdbcOutputPluginTest
|
26
|
-
{
|
27
|
-
private boolean useJtdsDriver = false;
|
28
|
-
|
29
|
-
|
30
|
-
@Override
|
31
|
-
protected void prepare() throws SQLException {
|
32
|
-
tester.addPlugin(OutputPlugin.class, "sqlserver", SQLServerOutputPlugin.class);
|
33
|
-
|
34
|
-
try {
|
35
|
-
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
36
|
-
} catch (ClassNotFoundException e) {
|
37
|
-
System.err.println("Warning: you should put 'sqljdbc41.jar' in 'embulk-output-sqlserver/driver' directory in order to test.");
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
|
41
|
-
try {
|
42
|
-
connect();
|
43
|
-
enabled = true;
|
44
|
-
} catch (Throwable t) {
|
45
|
-
System.out.println(t);
|
46
|
-
} finally {
|
47
|
-
if (!enabled) {
|
48
|
-
System.out.println(String.format(ENGLISH, "Warning: you should prepare database in order to test (server = %s, port = %d, database = %s, user = %s, password = %s).",
|
49
|
-
getHost(), getPort(), getDatabase(), getUser(), getPassword()));
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
@Test
|
55
|
-
public void testInsertDirect() throws Exception
|
56
|
-
{
|
57
|
-
String table = "TEST1";
|
58
|
-
|
59
|
-
dropTable(table);
|
60
|
-
createTable(table);
|
61
|
-
insertRecord(table);
|
62
|
-
|
63
|
-
test("/sqlserver/yml/test-insert-direct.yml");
|
64
|
-
|
65
|
-
assertTable(1, table);
|
66
|
-
}
|
67
|
-
|
68
|
-
@Test
|
69
|
-
public void testInsertDirectCreate() throws Exception
|
70
|
-
{
|
71
|
-
String table = "TEST1";
|
72
|
-
|
73
|
-
dropTable(table);
|
74
|
-
|
75
|
-
test("/sqlserver/yml/test-insert-direct.yml");
|
76
|
-
|
77
|
-
assertGeneratedTable(table);
|
78
|
-
}
|
79
|
-
|
80
|
-
@Test
|
81
|
-
public void testInsert() throws Exception
|
82
|
-
{
|
83
|
-
String table = "TEST1";
|
84
|
-
|
85
|
-
dropTable(table);
|
86
|
-
createTable(table);
|
87
|
-
insertRecord(table);
|
88
|
-
|
89
|
-
test("/sqlserver/yml/test-insert.yml");
|
90
|
-
|
91
|
-
assertTable(1, table);
|
92
|
-
}
|
93
|
-
|
94
|
-
@Test
|
95
|
-
public void testInsertCreate() throws Exception
|
96
|
-
{
|
97
|
-
String table = "TEST1";
|
98
|
-
|
99
|
-
dropTable(table);
|
100
|
-
|
101
|
-
test("/sqlserver/yml/test-insert.yml");
|
102
|
-
|
103
|
-
assertGeneratedTable(table);
|
104
|
-
}
|
105
|
-
|
106
|
-
@Test
|
107
|
-
public void testTruncateInsert() throws Exception
|
108
|
-
{
|
109
|
-
String table = "TEST1";
|
110
|
-
|
111
|
-
dropTable(table);
|
112
|
-
createTable(table);
|
113
|
-
insertRecord(table);
|
114
|
-
|
115
|
-
test("/sqlserver/yml/test-truncate-insert.yml");
|
116
|
-
|
117
|
-
assertTable(0, table);
|
118
|
-
}
|
119
|
-
|
120
|
-
@Test
|
121
|
-
public void testReplace() throws Exception
|
122
|
-
{
|
123
|
-
String table = "TEST1";
|
124
|
-
|
125
|
-
dropTable(table);
|
126
|
-
createTable(table);
|
127
|
-
insertRecord(table);
|
128
|
-
|
129
|
-
test("/sqlserver/yml/test-replace.yml");
|
130
|
-
|
131
|
-
assertGeneratedTable(table);
|
132
|
-
}
|
133
|
-
|
134
|
-
@Test
|
135
|
-
public void testReplaceLongName() throws Exception
|
136
|
-
{
|
137
|
-
String table = "TEST___A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789";
|
138
|
-
assertEquals(127, table.length());
|
139
|
-
|
140
|
-
dropTable(table);
|
141
|
-
createTable(table);
|
142
|
-
insertRecord(table);
|
143
|
-
|
144
|
-
test("/sqlserver/yml/test-replace-long-name.yml");
|
145
|
-
|
146
|
-
assertGeneratedTable(table);
|
147
|
-
}
|
148
|
-
|
149
|
-
@Test
|
150
|
-
public void testReplaceCreate() throws Exception
|
151
|
-
{
|
152
|
-
String table = "TEST1";
|
153
|
-
|
154
|
-
dropTable(table);
|
155
|
-
|
156
|
-
test("/sqlserver/yml/test-replace.yml");
|
157
|
-
|
158
|
-
assertGeneratedTable(table);
|
159
|
-
}
|
160
|
-
|
161
|
-
@Test
|
162
|
-
public void testStringToTimestamp() throws Exception
|
163
|
-
{
|
164
|
-
String table = "TEST1";
|
165
|
-
|
166
|
-
dropTable(table);
|
167
|
-
createTable(table);
|
168
|
-
insertRecord(table);
|
169
|
-
|
170
|
-
test("/sqlserver/yml/test-string-timestamp.yml");
|
171
|
-
|
172
|
-
assertTable(1, table, true);
|
173
|
-
}
|
174
|
-
|
175
|
-
@Test
|
176
|
-
public void testNativeString() throws Exception
|
177
|
-
{
|
178
|
-
if (!enabled) {
|
179
|
-
return;
|
180
|
-
}
|
181
|
-
|
182
|
-
String table = "TEST2";
|
183
|
-
|
184
|
-
dropTable(table);
|
185
|
-
executeSQL(String.format("CREATE TABLE %S (ITEM1 CHAR(4), ITEM2 VARCHAR(8), ITEM3 TEXT, ITEM4 NCHAR(4), ITEM5 NVARCHAR(8), ITEM6 NTEXT)", table));
|
186
|
-
|
187
|
-
test("/sqlserver/yml/test-native-string.yml");
|
188
|
-
|
189
|
-
List<List<Object>> rows = select(table);
|
190
|
-
assertEquals(2, rows.size());
|
191
|
-
{
|
192
|
-
List<Object> row = rows.get(0);
|
193
|
-
assertEquals("A001", row.get(0));
|
194
|
-
assertEquals("TEST", row.get(1));
|
195
|
-
assertEquals("A", row.get(2));
|
196
|
-
assertEquals("あいうえ", row.get(3));
|
197
|
-
assertEquals("あいうえおかきく", row.get(4));
|
198
|
-
assertEquals("あいうえお", row.get(5));
|
199
|
-
}
|
200
|
-
{
|
201
|
-
List<Object> row = rows.get(1);
|
202
|
-
assertEquals("A002", row.get(0));
|
203
|
-
assertEquals(null, row.get(1));
|
204
|
-
assertEquals(null, row.get(2));
|
205
|
-
assertEquals(null, row.get(3));
|
206
|
-
assertEquals(null, row.get(4));
|
207
|
-
assertEquals(null, row.get(5));
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
@Test
|
212
|
-
public void testNativeInteger() throws Exception
|
213
|
-
{
|
214
|
-
if (!enabled) {
|
215
|
-
return;
|
216
|
-
}
|
217
|
-
|
218
|
-
String table = "TEST3";
|
219
|
-
|
220
|
-
dropTable(table);
|
221
|
-
executeSQL(String.format("CREATE TABLE %S (ITEM1 TINYINT, ITEM2 SMALLINT, ITEM3 INT, ITEM4 BIGINT, ITEM5 BIT)", table));
|
222
|
-
|
223
|
-
test("/sqlserver/yml/test-native-integer.yml");
|
224
|
-
|
225
|
-
List<List<Object>> rows = select(table);
|
226
|
-
assertEquals(2, rows.size());
|
227
|
-
{
|
228
|
-
List<Object> row = rows.get(0);
|
229
|
-
assertEquals((short)1, row.get(0));
|
230
|
-
assertEquals((short)1111, row.get(1));
|
231
|
-
assertEquals(11111111, row.get(2));
|
232
|
-
assertEquals(111111111111L, row.get(3));
|
233
|
-
assertEquals(true, row.get(4));
|
234
|
-
}
|
235
|
-
{
|
236
|
-
List<Object> row = rows.get(1);
|
237
|
-
assertEquals((short)2, row.get(0));
|
238
|
-
assertEquals(null, row.get(1));
|
239
|
-
assertEquals(null, row.get(2));
|
240
|
-
assertEquals(null, row.get(3));
|
241
|
-
assertEquals(null, row.get(4));
|
242
|
-
}
|
243
|
-
}
|
244
|
-
|
245
|
-
@Test
|
246
|
-
public void testNativeDecimal() throws Exception
|
247
|
-
{
|
248
|
-
if (!enabled) {
|
249
|
-
return;
|
250
|
-
}
|
251
|
-
|
252
|
-
String table = "TEST4";
|
253
|
-
|
254
|
-
dropTable(table);
|
255
|
-
executeSQL(String.format("CREATE TABLE %S (ITEM1 DECIMAL(20,2), ITEM2 NUMERIC(20,2), ITEM3 SMALLMONEY, ITEM4 MONEY, ITEM5 REAL, ITEM6 FLOAT)", table));
|
256
|
-
|
257
|
-
test("/sqlserver/yml/test-native-decimal.yml");
|
258
|
-
|
259
|
-
List<List<Object>> rows = select(table);
|
260
|
-
assertEquals(2, rows.size());
|
261
|
-
{
|
262
|
-
List<Object> row = rows.get(0);
|
263
|
-
assertEquals(new BigDecimal("1.20"), row.get(0));
|
264
|
-
assertEquals(new BigDecimal("12345678901234567.89"), row.get(1));
|
265
|
-
assertEquals(new BigDecimal("123.4500"), row.get(2));
|
266
|
-
assertEquals(new BigDecimal("678.9000"), row.get(3));
|
267
|
-
assertEquals(0.01234F, row.get(4));
|
268
|
-
assertEquals(0.05678D, row.get(5));
|
269
|
-
}
|
270
|
-
{
|
271
|
-
List<Object> row = rows.get(1);
|
272
|
-
assertEquals(new BigDecimal("2.30"), row.get(0));
|
273
|
-
assertEquals(null, row.get(1));
|
274
|
-
assertEquals(null, row.get(2));
|
275
|
-
assertEquals(null, row.get(3));
|
276
|
-
assertEquals(null, row.get(4));
|
277
|
-
assertEquals(null, row.get(5));
|
278
|
-
}
|
279
|
-
}
|
280
|
-
|
281
|
-
@Test
|
282
|
-
public void testNativeDate() throws Exception
|
283
|
-
{
|
284
|
-
if (!enabled) {
|
285
|
-
return;
|
286
|
-
}
|
287
|
-
|
288
|
-
String table = "TEST5";
|
289
|
-
|
290
|
-
dropTable(table);
|
291
|
-
executeSQL(String.format("CREATE TABLE %S (ITEM1 DATE, ITEM2 SMALLDATETIME, ITEM3 DATETIME, ITEM4 DATETIME2, ITEM5 DATETIME2(2), ITEM6 TIME, ITEM7 TIME(2))", table));
|
292
|
-
|
293
|
-
test("/sqlserver/yml/test-native-date.yml");
|
294
|
-
|
295
|
-
List<List<Object>> rows = select(table);
|
296
|
-
assertEquals(2, rows.size());
|
297
|
-
{
|
298
|
-
List<Object> row = rows.get(0);
|
299
|
-
assertEquals(createDate("2016/01/23"), row.get(0));
|
300
|
-
assertEquals(createTimestamp("2016/01/24 11:23:00", 0), row.get(1));
|
301
|
-
assertEquals(createTimestamp("2016/01/25 11:22:33", 457000000), row.get(2));
|
302
|
-
// Embulk timestamp doesn't support values under microseconds.
|
303
|
-
assertEquals(createTimestamp("2016/01/26 11:22:33", 123456000), row.get(3));
|
304
|
-
assertEquals(createTimestamp("2016/01/27 11:22:33", 890000000), row.get(4));
|
305
|
-
// Embulk timestamp doesn't support values under microseconds.
|
306
|
-
assertEquals(createTime("11:22:33", 123456000), row.get(5));
|
307
|
-
assertEquals(createTime("11:22:33", 890000000), row.get(6));
|
308
|
-
}
|
309
|
-
{
|
310
|
-
List<Object> row = rows.get(1);
|
311
|
-
assertEquals(null, row.get(0));
|
312
|
-
assertEquals(null, row.get(1));
|
313
|
-
assertEquals(null, row.get(2));
|
314
|
-
assertEquals(null, row.get(3));
|
315
|
-
assertEquals(null, row.get(4));
|
316
|
-
assertEquals(null, row.get(5));
|
317
|
-
assertEquals(null, row.get(6));
|
318
|
-
}
|
319
|
-
}
|
320
|
-
|
321
|
-
@Test
|
322
|
-
public void testNative() throws Exception
|
323
|
-
{
|
324
|
-
String table = "TEST1";
|
325
|
-
|
326
|
-
dropTable(table);
|
327
|
-
createTable(table);
|
328
|
-
insertRecord(table);
|
329
|
-
|
330
|
-
test("/sqlserver/yml/test-native.yml");
|
331
|
-
|
332
|
-
assertTable(1, table);
|
333
|
-
}
|
334
|
-
|
335
|
-
@Test
|
336
|
-
public void testJtds() throws Exception
|
337
|
-
{
|
338
|
-
useJtdsDriver = true;
|
339
|
-
try {
|
340
|
-
connect();
|
341
|
-
} catch (Throwable t) {
|
342
|
-
System.out.println(t);
|
343
|
-
System.out.println("Warning: jTDS driver can't connect to database.");
|
344
|
-
System.out.println(String.format(ENGLISH, "(server = %s, port = %d, database = %s, user = %s, password = %s)",
|
345
|
-
getHost(), getPort(), getDatabase(), getUser(), getPassword()));
|
346
|
-
return;
|
347
|
-
}
|
348
|
-
|
349
|
-
try {
|
350
|
-
String table = "TEST1";
|
351
|
-
dropTable(table);
|
352
|
-
createTable(table);
|
353
|
-
insertRecord(table);
|
354
|
-
test("/sqlserver/yml/test-jtds.yml");
|
355
|
-
assertTableJtds(1, table);
|
356
|
-
} finally {
|
357
|
-
useJtdsDriver = false;
|
358
|
-
}
|
359
|
-
}
|
360
|
-
|
361
|
-
@Test
|
362
|
-
public void testMerge() throws Exception
|
363
|
-
{
|
364
|
-
if (!enabled) {
|
365
|
-
return;
|
366
|
-
}
|
367
|
-
|
368
|
-
String table = "TEST6";
|
369
|
-
|
370
|
-
dropTable(table);
|
371
|
-
executeSQL(String.format("CREATE TABLE %S (ITEM1 INT, ITEM2 INT, ITEM3 VARCHAR(4), PRIMARY KEY(ITEM1, ITEM2))", table));
|
372
|
-
executeSQL(String.format("INSERT INTO %S VALUES(10, 20, 'A')", table));
|
373
|
-
executeSQL(String.format("INSERT INTO %S VALUES(10, 21, 'B')", table));
|
374
|
-
executeSQL(String.format("INSERT INTO %S VALUES(11, 20, 'C')", table));
|
375
|
-
|
376
|
-
test("/sqlserver/yml/test-merge.yml");
|
377
|
-
|
378
|
-
assertMergedTable(table);
|
379
|
-
}
|
380
|
-
|
381
|
-
@Test
|
382
|
-
public void testMergeWithKeys() throws Exception
|
383
|
-
{
|
384
|
-
if (!enabled) {
|
385
|
-
return;
|
386
|
-
}
|
387
|
-
|
388
|
-
String table = "TEST6b";
|
389
|
-
|
390
|
-
dropTable(table);
|
391
|
-
executeSQL(String.format("CREATE TABLE %S (ITEM1 INT, ITEM2 INT, ITEM3 VARCHAR(4))", table));
|
392
|
-
executeSQL(String.format("INSERT INTO %S VALUES(10, 20, 'A')", table));
|
393
|
-
executeSQL(String.format("INSERT INTO %S VALUES(10, 21, 'B')", table));
|
394
|
-
executeSQL(String.format("INSERT INTO %S VALUES(11, 20, 'C')", table));
|
395
|
-
|
396
|
-
test("/sqlserver/yml/test-merge-keys.yml");
|
397
|
-
|
398
|
-
assertMergedTable(table);
|
399
|
-
}
|
400
|
-
|
401
|
-
@Test
|
402
|
-
public void testMergeWithRule() throws Exception
|
403
|
-
{
|
404
|
-
if (!enabled) {
|
405
|
-
return;
|
406
|
-
}
|
407
|
-
|
408
|
-
String table = "TEST6";
|
409
|
-
|
410
|
-
dropTable(table);
|
411
|
-
executeSQL(String.format("CREATE TABLE %S (ITEM1 INT, ITEM2 INT, ITEM3 VARCHAR(4), PRIMARY KEY(ITEM1, ITEM2))", table));
|
412
|
-
executeSQL(String.format("INSERT INTO %S VALUES(10, 20, 'A')", table));
|
413
|
-
executeSQL(String.format("INSERT INTO %S VALUES(10, 21, 'B')", table));
|
414
|
-
executeSQL(String.format("INSERT INTO %S VALUES(11, 20, 'C')", table));
|
415
|
-
|
416
|
-
test("/sqlserver/yml/test-merge-rule.yml");
|
417
|
-
|
418
|
-
List<List<Object>> rows = select(table);
|
419
|
-
assertEquals(6, rows.size());
|
420
|
-
{
|
421
|
-
List<Object> row = rows.get(0);
|
422
|
-
assertEquals(Integer.valueOf(10), row.get(0));
|
423
|
-
assertEquals(Integer.valueOf(20), row.get(1));
|
424
|
-
assertEquals("A", row.get(2));
|
425
|
-
}
|
426
|
-
{
|
427
|
-
List<Object> row = rows.get(1);
|
428
|
-
assertEquals(Integer.valueOf(10), row.get(0));
|
429
|
-
assertEquals(Integer.valueOf(21), row.get(1));
|
430
|
-
assertEquals("Baa", row.get(2));
|
431
|
-
}
|
432
|
-
{
|
433
|
-
List<Object> row = rows.get(2);
|
434
|
-
assertEquals(Integer.valueOf(10), row.get(0));
|
435
|
-
assertEquals(Integer.valueOf(22), row.get(1));
|
436
|
-
assertEquals("dd", row.get(2));
|
437
|
-
}
|
438
|
-
{
|
439
|
-
List<Object> row = rows.get(3);
|
440
|
-
assertEquals(Integer.valueOf(11), row.get(0));
|
441
|
-
assertEquals(Integer.valueOf(10), row.get(1));
|
442
|
-
assertEquals("bb", row.get(2));
|
443
|
-
}
|
444
|
-
{
|
445
|
-
List<Object> row = rows.get(4);
|
446
|
-
assertEquals(Integer.valueOf(11), row.get(0));
|
447
|
-
assertEquals(Integer.valueOf(20), row.get(1));
|
448
|
-
assertEquals("C", row.get(2));
|
449
|
-
}
|
450
|
-
{
|
451
|
-
List<Object> row = rows.get(5);
|
452
|
-
assertEquals(Integer.valueOf(12), row.get(0));
|
453
|
-
assertEquals(Integer.valueOf(20), row.get(1));
|
454
|
-
assertEquals("cc", row.get(2));
|
455
|
-
}
|
456
|
-
}
|
457
|
-
|
458
|
-
private void assertMergedTable(String table) throws Exception
|
459
|
-
{
|
460
|
-
List<List<Object>> rows = select(table);
|
461
|
-
assertEquals(6, rows.size());
|
462
|
-
{
|
463
|
-
List<Object> row = rows.get(0);
|
464
|
-
assertEquals(Integer.valueOf(10), row.get(0));
|
465
|
-
assertEquals(Integer.valueOf(20), row.get(1));
|
466
|
-
assertEquals("A", row.get(2));
|
467
|
-
}
|
468
|
-
{
|
469
|
-
List<Object> row = rows.get(1);
|
470
|
-
assertEquals(Integer.valueOf(10), row.get(0));
|
471
|
-
assertEquals(Integer.valueOf(21), row.get(1));
|
472
|
-
assertEquals("aa", row.get(2));
|
473
|
-
}
|
474
|
-
{
|
475
|
-
List<Object> row = rows.get(2);
|
476
|
-
assertEquals(Integer.valueOf(10), row.get(0));
|
477
|
-
assertEquals(Integer.valueOf(22), row.get(1));
|
478
|
-
assertEquals("dd", row.get(2));
|
479
|
-
}
|
480
|
-
{
|
481
|
-
List<Object> row = rows.get(3);
|
482
|
-
assertEquals(Integer.valueOf(11), row.get(0));
|
483
|
-
assertEquals(Integer.valueOf(10), row.get(1));
|
484
|
-
assertEquals("bb", row.get(2));
|
485
|
-
}
|
486
|
-
{
|
487
|
-
List<Object> row = rows.get(4);
|
488
|
-
assertEquals(Integer.valueOf(11), row.get(0));
|
489
|
-
assertEquals(Integer.valueOf(20), row.get(1));
|
490
|
-
assertEquals("C", row.get(2));
|
491
|
-
}
|
492
|
-
{
|
493
|
-
List<Object> row = rows.get(5);
|
494
|
-
assertEquals(Integer.valueOf(12), row.get(0));
|
495
|
-
assertEquals(Integer.valueOf(20), row.get(1));
|
496
|
-
assertEquals("cc", row.get(2));
|
497
|
-
}
|
498
|
-
}
|
499
|
-
|
500
|
-
|
501
|
-
private void assertTable(int skip, String table) throws Exception
|
502
|
-
{
|
503
|
-
assertTable(skip, table, false);
|
504
|
-
}
|
505
|
-
|
506
|
-
private void assertTableJtds(int skip, String table) throws Exception
|
507
|
-
{
|
508
|
-
List<List<Object>> rows = select(table);
|
509
|
-
assertEquals(skip + 3, rows.size());
|
510
|
-
rows = rows.subList(skip, skip + 3);
|
511
|
-
|
512
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
513
|
-
{
|
514
|
-
Iterator<Object> i2 = i1.next().iterator();
|
515
|
-
assertEquals("A001", i2.next());
|
516
|
-
assertEquals(0, i2.next());
|
517
|
-
assertEquals(1234, i2.next());
|
518
|
-
assertEquals(123456, i2.next());
|
519
|
-
assertEquals(12345678901L, i2.next());
|
520
|
-
assertEquals(false, i2.next());
|
521
|
-
assertEquals(new BigDecimal("1.23"), i2.next());
|
522
|
-
assertEquals(new BigDecimal("3.456"), i2.next());
|
523
|
-
assertEquals(new BigDecimal("12.3400"), i2.next());
|
524
|
-
assertEquals(new BigDecimal("123.4567"), i2.next());
|
525
|
-
assertEquals(Float.valueOf(0.1234567F), i2.next());
|
526
|
-
assertEquals(Double.valueOf(0.12345678901234D), i2.next());
|
527
|
-
assertEquals("a ", i2.next());
|
528
|
-
assertEquals("b", i2.next());
|
529
|
-
assertEquals("c", i2.next());
|
530
|
-
assertEquals("A ", i2.next());
|
531
|
-
assertEquals("B", i2.next());
|
532
|
-
assertEquals("C", i2.next());
|
533
|
-
assertEquals("2016-01-01", i2.next());
|
534
|
-
assertEquals(createTimestamp("2017/01/01 01:02:03", 123000000), i2.next());
|
535
|
-
// Embulk timestamp doesn't support values under microseconds.
|
536
|
-
assertEquals("2018-01-01 01:02:03.1234560", i2.next().toString());
|
537
|
-
|
538
|
-
assertEquals(createTimestamp("2019/01/01 01:02:03", 120000000).toString(), i2.next());
|
539
|
-
assertEquals(createTimestamp("2020/01/01 01:02:00", 0), i2.next());
|
540
|
-
|
541
|
-
// Embulk timestamp doesn't support values under microseconds.
|
542
|
-
assertEquals("03:04:05.1234560", i2.next().toString());
|
543
|
-
assertEquals("06:07:08.12", i2.next().toString());
|
544
|
-
}
|
545
|
-
{
|
546
|
-
Iterator<Object> i2 = i1.next().iterator();
|
547
|
-
assertEquals("A002", i2.next());
|
548
|
-
assertEquals(255, i2.next());
|
549
|
-
assertEquals(-32768, i2.next());
|
550
|
-
assertEquals(-2147483648, i2.next());
|
551
|
-
assertEquals(-9223372036854775808L, i2.next());
|
552
|
-
assertEquals(true, i2.next());
|
553
|
-
assertEquals(new BigDecimal("-9999999999.99"), i2.next());
|
554
|
-
assertEquals(new BigDecimal("-99.999"), i2.next());
|
555
|
-
assertEquals(new BigDecimal("-214748.3648"), i2.next());
|
556
|
-
assertEquals(new BigDecimal("-922337203685477.5808"), i2.next());
|
557
|
-
assertEquals(Float.valueOf(-9999000000F), i2.next());
|
558
|
-
assertEquals(Double.valueOf(-999999999999000000D), i2.next());
|
559
|
-
// char, varchar, text don't be capable on Unicode chars
|
560
|
-
//assertEquals("あい", i2.next());
|
561
|
-
i2.next();
|
562
|
-
//assertEquals("あいうえ", i2.next());
|
563
|
-
i2.next();
|
564
|
-
//assertEquals("あいうえお", i2.next());
|
565
|
-
i2.next();
|
566
|
-
|
567
|
-
// nchar, nvarcar, ntext
|
568
|
-
assertEquals("かき ", i2.next());
|
569
|
-
assertEquals("かきくけ", i2.next());
|
570
|
-
assertEquals("かきくけこ", i2.next());
|
571
|
-
|
572
|
-
assertEquals("2016-12-31", i2.next());
|
573
|
-
assertEquals(createTimestamp("2017/12/31 23:59:59", 997000000), i2.next());
|
574
|
-
// Embulk timestamp doesn't support values under microseconds.
|
575
|
-
assertEquals("2018-12-31 23:59:59.9999990", i2.next().toString());
|
576
|
-
assertEquals(createTimestamp("2019/12/31 23:59:59", 990000000).toString(), i2.next());
|
577
|
-
assertEquals(createTimestamp("2021/01/01 00:00:00", 0), i2.next());
|
578
|
-
// Embulk timestamp doesn't support values under microseconds.
|
579
|
-
assertEquals("23:59:59.9999990", i2.next().toString());
|
580
|
-
assertEquals("23:59:59.99", i2.next().toString());
|
581
|
-
}
|
582
|
-
{
|
583
|
-
Iterator<Object> i2 = i1.next().iterator();
|
584
|
-
assertEquals("A003", i2.next());
|
585
|
-
assertEquals(null, i2.next());
|
586
|
-
assertEquals(null, i2.next());
|
587
|
-
assertEquals(null, i2.next());
|
588
|
-
assertEquals(null, i2.next());
|
589
|
-
assertEquals(null, i2.next());
|
590
|
-
assertEquals(null, i2.next());
|
591
|
-
assertEquals(null, i2.next());
|
592
|
-
assertEquals(null, i2.next());
|
593
|
-
assertEquals(null, i2.next());
|
594
|
-
assertEquals(null, i2.next());
|
595
|
-
assertEquals(null, i2.next());
|
596
|
-
assertEquals(null, i2.next());
|
597
|
-
assertEquals(null, i2.next());
|
598
|
-
assertEquals(null, i2.next());
|
599
|
-
assertEquals(null, i2.next());
|
600
|
-
assertEquals(null, i2.next());
|
601
|
-
assertEquals(null, i2.next());
|
602
|
-
assertEquals(null, i2.next());
|
603
|
-
assertEquals(null, i2.next());
|
604
|
-
assertEquals(null, i2.next());
|
605
|
-
assertEquals(null, i2.next());
|
606
|
-
assertEquals(null, i2.next());
|
607
|
-
assertEquals(null, i2.next());
|
608
|
-
}
|
609
|
-
}
|
610
|
-
|
611
|
-
private void assertTable(int skip, String table, boolean precise) throws Exception
|
612
|
-
{
|
613
|
-
if (!enabled) {
|
614
|
-
return;
|
615
|
-
}
|
616
|
-
|
617
|
-
List<List<Object>> rows = select(table);
|
618
|
-
assertEquals(skip + 3, rows.size());
|
619
|
-
rows = rows.subList(skip, skip + 3);
|
620
|
-
|
621
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
622
|
-
{
|
623
|
-
Iterator<Object> i2 = i1.next().iterator();
|
624
|
-
assertEquals("A001", i2.next());
|
625
|
-
assertEquals((short)0, i2.next());
|
626
|
-
assertEquals((short)1234, i2.next());
|
627
|
-
assertEquals(123456, i2.next());
|
628
|
-
assertEquals(12345678901L, i2.next());
|
629
|
-
assertEquals(false, i2.next());
|
630
|
-
assertEquals(new BigDecimal("1.23"), i2.next());
|
631
|
-
assertEquals(new BigDecimal("3.456"), i2.next());
|
632
|
-
assertEquals(new BigDecimal("12.3400"), i2.next());
|
633
|
-
assertEquals(new BigDecimal("123.4567"), i2.next());
|
634
|
-
assertEquals(Float.valueOf(0.1234567F), i2.next());
|
635
|
-
assertEquals(Double.valueOf(0.12345678901234D), i2.next());
|
636
|
-
assertEquals("a ", i2.next());
|
637
|
-
assertEquals("b", i2.next());
|
638
|
-
assertEquals("c", i2.next());
|
639
|
-
assertEquals("A ", i2.next());
|
640
|
-
assertEquals("B", i2.next());
|
641
|
-
assertEquals("C", i2.next());
|
642
|
-
assertEquals(createDate("2016/01/01"), i2.next());
|
643
|
-
assertEquals(createTimestamp("2017/01/01 01:02:03", 123000000), i2.next());
|
644
|
-
// Embulk timestamp doesn't support values under microseconds.
|
645
|
-
assertEquals(createTimestamp("2018/01/01 01:02:03", precise? 123456700 : 123456000), i2.next());
|
646
|
-
assertEquals(createTimestamp("2019/01/01 01:02:03", 120000000), i2.next());
|
647
|
-
assertEquals(createTimestamp("2020/01/01 01:02:00", 0), i2.next());
|
648
|
-
// Embulk timestamp doesn't support values under microseconds.
|
649
|
-
assertEquals(createTime("03:04:05", precise? 123456700 : 123456000), i2.next());
|
650
|
-
assertEquals(createTime("06:07:08", 120000000), i2.next());
|
651
|
-
}
|
652
|
-
{
|
653
|
-
Iterator<Object> i2 = i1.next().iterator();
|
654
|
-
assertEquals("A002", i2.next());
|
655
|
-
assertEquals((short)255, i2.next());
|
656
|
-
assertEquals((short)-32768, i2.next());
|
657
|
-
assertEquals(-2147483648, i2.next());
|
658
|
-
assertEquals(-9223372036854775808L, i2.next());
|
659
|
-
assertEquals(true, i2.next());
|
660
|
-
assertEquals(new BigDecimal("-9999999999.99"), i2.next());
|
661
|
-
assertEquals(new BigDecimal("-99.999"), i2.next());
|
662
|
-
assertEquals(new BigDecimal("-214748.3648"), i2.next());
|
663
|
-
assertEquals(new BigDecimal("-922337203685477.5808"), i2.next());
|
664
|
-
assertEquals(Float.valueOf(-9999000000F), i2.next());
|
665
|
-
assertEquals(Double.valueOf(-999999999999000000D), i2.next());
|
666
|
-
assertEquals("あい", i2.next());
|
667
|
-
assertEquals("あいうえ", i2.next());
|
668
|
-
assertEquals("あいうえお", i2.next());
|
669
|
-
assertEquals("かき ", i2.next());
|
670
|
-
assertEquals("かきくけ", i2.next());
|
671
|
-
assertEquals("かきくけこ", i2.next());
|
672
|
-
assertEquals(createDate("2016/12/31"), i2.next());
|
673
|
-
assertEquals(createTimestamp("2017/12/31 23:59:59", 997000000), i2.next());
|
674
|
-
// Embulk timestamp doesn't support values under microseconds.
|
675
|
-
assertEquals(createTimestamp("2018/12/31 23:59:59", precise? 999999900 : 999999000), i2.next());
|
676
|
-
assertEquals(createTimestamp("2019/12/31 23:59:59", 990000000), i2.next());
|
677
|
-
assertEquals(createTimestamp("2021/01/01 00:00:00", 0), i2.next());
|
678
|
-
// Embulk timestamp doesn't support values under microseconds.
|
679
|
-
assertEquals(createTime("23:59:59", precise? 999999900 : 999999000), i2.next());
|
680
|
-
assertEquals(createTime("23:59:59", 990000000), i2.next());
|
681
|
-
}
|
682
|
-
{
|
683
|
-
Iterator<Object> i2 = i1.next().iterator();
|
684
|
-
assertEquals("A003", i2.next());
|
685
|
-
assertEquals(null, i2.next());
|
686
|
-
assertEquals(null, i2.next());
|
687
|
-
assertEquals(null, i2.next());
|
688
|
-
assertEquals(null, i2.next());
|
689
|
-
assertEquals(null, i2.next());
|
690
|
-
assertEquals(null, i2.next());
|
691
|
-
assertEquals(null, i2.next());
|
692
|
-
assertEquals(null, i2.next());
|
693
|
-
assertEquals(null, i2.next());
|
694
|
-
assertEquals(null, i2.next());
|
695
|
-
assertEquals(null, i2.next());
|
696
|
-
assertEquals(null, i2.next());
|
697
|
-
assertEquals(null, i2.next());
|
698
|
-
assertEquals(null, i2.next());
|
699
|
-
assertEquals(null, i2.next());
|
700
|
-
assertEquals(null, i2.next());
|
701
|
-
assertEquals(null, i2.next());
|
702
|
-
assertEquals(null, i2.next());
|
703
|
-
assertEquals(null, i2.next());
|
704
|
-
assertEquals(null, i2.next());
|
705
|
-
assertEquals(null, i2.next());
|
706
|
-
assertEquals(null, i2.next());
|
707
|
-
assertEquals(null, i2.next());
|
708
|
-
}
|
709
|
-
}
|
710
|
-
|
711
|
-
private void assertGeneratedTable(String table) throws Exception
|
712
|
-
{
|
713
|
-
if (!enabled) {
|
714
|
-
return;
|
715
|
-
}
|
716
|
-
|
717
|
-
List<List<Object>> rows = select(table);
|
718
|
-
assertEquals(3, rows.size());
|
719
|
-
|
720
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
721
|
-
{
|
722
|
-
Iterator<Object> i2 = i1.next().iterator();
|
723
|
-
assertEquals("A001", i2.next());
|
724
|
-
assertEquals(Long.valueOf(0), i2.next());
|
725
|
-
assertEquals(Long.valueOf(1234), i2.next());
|
726
|
-
assertEquals(Long.valueOf(123456), i2.next());
|
727
|
-
assertEquals(Long.valueOf(12345678901L), i2.next());
|
728
|
-
assertEquals(Boolean.FALSE, i2.next());
|
729
|
-
assertEquals("1.23", i2.next());
|
730
|
-
assertEquals("3.456", i2.next());
|
731
|
-
assertEquals("12.34", i2.next());
|
732
|
-
assertEquals("123.4567", i2.next());
|
733
|
-
assertEquals(Double.valueOf(0.1234567D), i2.next());
|
734
|
-
assertEquals(Double.valueOf(0.12345678901234D), i2.next());
|
735
|
-
assertEquals("a", i2.next());
|
736
|
-
assertEquals("b", i2.next());
|
737
|
-
assertEquals("c", i2.next());
|
738
|
-
assertEquals("A", i2.next());
|
739
|
-
assertEquals("B", i2.next());
|
740
|
-
assertEquals("C", i2.next());
|
741
|
-
assertEquals(createTimestamp("2016/01/01 00:00:00", 0), i2.next());
|
742
|
-
assertEquals(createTimestamp("2017/01/01 01:02:03", 123000000), i2.next());
|
743
|
-
// Embulk timestamp doesn't support values under microseconds.
|
744
|
-
//assertEquals(createTimestamp("2018/01/01 01:02:03", 123456700), i2.next());
|
745
|
-
assertEquals(createTimestamp("2018/01/01 01:02:03", 123456000), i2.next());
|
746
|
-
assertEquals(createTimestamp("2019/01/01 01:02:03", 120000000), i2.next());
|
747
|
-
assertEquals(createTimestamp("2020/01/01 01:02:03", 0), i2.next());
|
748
|
-
// Embulk timestamp doesn't support values under microseconds.
|
749
|
-
//assertEquals(createTime("03:04:05", 123456700), new PreciseTime((Timestamp)i2.next()));
|
750
|
-
assertEquals(createTime("03:04:05", 123456000), new PreciseTime((Timestamp)i2.next()));
|
751
|
-
assertEquals(createTime("06:07:08", 120000000), new PreciseTime((Timestamp)i2.next()));
|
752
|
-
}
|
753
|
-
{
|
754
|
-
Iterator<Object> i2 = i1.next().iterator();
|
755
|
-
assertEquals("A002", i2.next());
|
756
|
-
assertEquals(Long.valueOf((short)255), i2.next());
|
757
|
-
assertEquals(Long.valueOf((short)-32768), i2.next());
|
758
|
-
assertEquals(Long.valueOf(-2147483648), i2.next());
|
759
|
-
assertEquals(Long.valueOf(-9223372036854775808L), i2.next());
|
760
|
-
assertEquals(Boolean.TRUE, i2.next());
|
761
|
-
assertEquals("-9999999999.99", i2.next());
|
762
|
-
assertEquals("-99.999", i2.next());
|
763
|
-
assertEquals("-214748.3648", i2.next());
|
764
|
-
assertEquals("-922337203685477.5808", i2.next());
|
765
|
-
assertEquals(Double.valueOf(-9999000000D), i2.next());
|
766
|
-
assertEquals(Double.valueOf(-999999999999000000D), i2.next());
|
767
|
-
assertEquals("あい", i2.next());
|
768
|
-
assertEquals("あいうえ", i2.next());
|
769
|
-
assertEquals("あいうえお", i2.next());
|
770
|
-
assertEquals("かき", i2.next());
|
771
|
-
assertEquals("かきくけ", i2.next());
|
772
|
-
assertEquals("かきくけこ", i2.next());
|
773
|
-
assertEquals(createTimestamp("2016/12/31 00:00:00", 0), i2.next());
|
774
|
-
assertEquals(createTimestamp("2017/12/31 23:59:59", 997000000), i2.next());
|
775
|
-
// Embulk timestamp doesn't support values under microseconds.
|
776
|
-
//assertEquals(createTimestamp("2018/12/31 23:59:59", 999999900), i2.next());
|
777
|
-
assertEquals(createTimestamp("2018/12/31 23:59:59", 999999000), i2.next());
|
778
|
-
assertEquals(createTimestamp("2019/12/31 23:59:59", 990000000), i2.next());
|
779
|
-
assertEquals(createTimestamp("2020/12/31 23:59:59", 0), i2.next());
|
780
|
-
// Embulk timestamp doesn't support values under microseconds.
|
781
|
-
//assertEquals(createTime("23:59:59", 999999900), new PreciseTime((Timestamp)i2.next()));
|
782
|
-
assertEquals(createTime("23:59:59", 999999000), new PreciseTime((Timestamp)i2.next()));
|
783
|
-
assertEquals(createTime("23:59:59", 990000000), new PreciseTime((Timestamp)i2.next()));
|
784
|
-
}
|
785
|
-
{
|
786
|
-
Iterator<Object> i2 = i1.next().iterator();
|
787
|
-
assertEquals("A003", i2.next());
|
788
|
-
assertEquals(null, i2.next());
|
789
|
-
assertEquals(null, i2.next());
|
790
|
-
assertEquals(null, i2.next());
|
791
|
-
assertEquals(null, i2.next());
|
792
|
-
assertEquals(null, i2.next());
|
793
|
-
assertEquals(null, i2.next());
|
794
|
-
assertEquals(null, i2.next());
|
795
|
-
assertEquals(null, i2.next());
|
796
|
-
assertEquals(null, i2.next());
|
797
|
-
assertEquals(null, i2.next());
|
798
|
-
assertEquals(null, i2.next());
|
799
|
-
assertEquals(null, i2.next());
|
800
|
-
assertEquals(null, i2.next());
|
801
|
-
assertEquals(null, i2.next());
|
802
|
-
assertEquals(null, i2.next());
|
803
|
-
assertEquals(null, i2.next());
|
804
|
-
assertEquals(null, i2.next());
|
805
|
-
assertEquals(null, i2.next());
|
806
|
-
assertEquals(null, i2.next());
|
807
|
-
assertEquals(null, i2.next());
|
808
|
-
assertEquals(null, i2.next());
|
809
|
-
assertEquals(null, i2.next());
|
810
|
-
assertEquals(null, i2.next());
|
811
|
-
assertEquals(null, i2.next());
|
812
|
-
}
|
813
|
-
}
|
814
|
-
|
815
|
-
@Override
|
816
|
-
protected Object getValue(ResultSet resultSet, int index) throws SQLException {
|
817
|
-
if (resultSet.getMetaData().getColumnTypeName(index).equals("time")) {
|
818
|
-
Timestamp timestamp = resultSet.getTimestamp(index);
|
819
|
-
if (timestamp == null) {
|
820
|
-
return null;
|
821
|
-
}
|
822
|
-
return new PreciseTime(timestamp);
|
823
|
-
}
|
824
|
-
return super.getValue(resultSet, index);
|
825
|
-
}
|
826
|
-
|
827
|
-
private java.sql.Date createDate(String s) throws ParseException
|
828
|
-
{
|
829
|
-
DateFormat format = new SimpleDateFormat("yyyy/MM/dd");
|
830
|
-
Date date = format.parse(s);
|
831
|
-
return new java.sql.Date(date.getTime());
|
832
|
-
}
|
833
|
-
|
834
|
-
private Timestamp createTimestamp(String s, int nanos) throws ParseException
|
835
|
-
{
|
836
|
-
DateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
837
|
-
Date date = format.parse(s);
|
838
|
-
Timestamp timestamp = new Timestamp(date.getTime());
|
839
|
-
timestamp.setNanos(nanos);
|
840
|
-
return timestamp;
|
841
|
-
}
|
842
|
-
|
843
|
-
private PreciseTime createTime(String s, int nanos) throws ParseException
|
844
|
-
{
|
845
|
-
DateFormat format = new SimpleDateFormat("HH:mm:ss");
|
846
|
-
Date date = format.parse(s);
|
847
|
-
return new PreciseTime(date.getTime(), nanos);
|
848
|
-
}
|
849
|
-
|
850
|
-
private void createTable(String table) throws SQLException
|
851
|
-
{
|
852
|
-
String sql = String.format("CREATE TABLE %s ("
|
853
|
-
+ "ID CHAR(4),"
|
854
|
-
+ "TINYINT_ITEM TINYINT,"
|
855
|
-
+ "SMALLINT_ITEM SMALLINT,"
|
856
|
-
+ "INT_ITEM INT,"
|
857
|
-
+ "BIGINT_ITEM BIGINT,"
|
858
|
-
+ "BIT_ITEM BIT,"
|
859
|
-
+ "DECIMAL_ITEM DECIMAL(12,2),"
|
860
|
-
+ "NUMERIC_ITEM NUMERIC(5,3),"
|
861
|
-
+ "SMALLMONEY_ITEM SMALLMONEY,"
|
862
|
-
+ "MONEY_ITEM MONEY,"
|
863
|
-
+ "REAL_ITEM REAL,"
|
864
|
-
+ "FLOAT_ITEM FLOAT,"
|
865
|
-
+ "CHAR_ITEM CHAR(4),"
|
866
|
-
+ "VARCHAR_ITEM VARCHAR(8),"
|
867
|
-
+ "TEXT_ITEM TEXT,"
|
868
|
-
+ "NCHAR_ITEM NCHAR(4),"
|
869
|
-
+ "NVARCHAR_ITEM NVARCHAR(8),"
|
870
|
-
+ "NTEXT_ITEM NTEXT,"
|
871
|
-
+ "DATE_ITEM DATE,"
|
872
|
-
+ "DATETIME_ITEM DATETIME,"
|
873
|
-
+ "DATETIME2_ITEM DATETIME2,"
|
874
|
-
+ "DATETIME2_2_ITEM DATETIME2(2),"
|
875
|
-
+ "SMALLDATETIME_ITEM SMALLDATETIME,"
|
876
|
-
+ "TIME_ITEM TIME,"
|
877
|
-
+ "TIME_2_ITEM TIME(2),"
|
878
|
-
+ "PRIMARY KEY (ID))", table);
|
879
|
-
executeSQL(sql);
|
880
|
-
}
|
881
|
-
|
882
|
-
private void insertRecord(String table) throws SQLException
|
883
|
-
{
|
884
|
-
executeSQL(String.format("INSERT INTO %s VALUES('9999',"
|
885
|
-
+ "NULL,"
|
886
|
-
+ "NULL,"
|
887
|
-
+ "NULL,"
|
888
|
-
+ "NULL,"
|
889
|
-
+ "NULL,"
|
890
|
-
+ "NULL,"
|
891
|
-
+ "NULL,"
|
892
|
-
+ "NULL,"
|
893
|
-
+ "NULL,"
|
894
|
-
+ "NULL,"
|
895
|
-
+ "NULL,"
|
896
|
-
+ "NULL,"
|
897
|
-
+ "NULL,"
|
898
|
-
+ "NULL,"
|
899
|
-
+ "NULL,"
|
900
|
-
+ "NULL,"
|
901
|
-
+ "NULL,"
|
902
|
-
+ "NULL,"
|
903
|
-
+ "NULL,"
|
904
|
-
+ "NULL,"
|
905
|
-
+ "NULL,"
|
906
|
-
+ "NULL,"
|
907
|
-
+ "NULL,"
|
908
|
-
+ "NULL)", table));
|
909
|
-
}
|
910
|
-
|
911
|
-
@Override
|
912
|
-
protected Connection connect() throws SQLException
|
913
|
-
{
|
914
|
-
String url;
|
915
|
-
if(useJtdsDriver) {
|
916
|
-
url = "jdbc:jtds:sqlserver://%s:%d/%s;useLOBs=false";
|
917
|
-
} else {
|
918
|
-
url = "jdbc:sqlserver://%s:%d;databasename=%s";
|
919
|
-
}
|
920
|
-
return DriverManager.getConnection(String.format(ENGLISH, url, getHost(), getPort(), getDatabase()), getUser(), getPassword());
|
921
|
-
}
|
922
|
-
|
923
|
-
}
|