PR feedback for tests

This commit is contained in:
Daylon Wilkins
2020-02-17 16:32:14 -08:00
committed by Daylon Wilkins
parent 080aeea015
commit acb3501a91
11 changed files with 283 additions and 387 deletions

View File

@@ -13,8 +13,7 @@ teardown() {
@test "back-compat: data check" {
for testdir in */; do
cd "$testdir"
run dolt status
[ "$status" -eq "0" ]
dolt status
run dolt branch
[ "$status" -eq "0" ]
[[ "$output" =~ "master" ]] || false
@@ -68,10 +67,8 @@ teardown() {
@test "back-compat: table operations" {
for testdir in */; do
cd "$testdir"
run dolt table cp abc copy
[ "$status" -eq "0" ]
run dolt table mv abc move
[ "$status" -eq "0" ]
dolt table cp abc copy
dolt table mv abc move
run dolt ls
[ "$status" -eq "0" ]
[[ "$output" =~ "copy" ]] || false
@@ -83,12 +80,9 @@ teardown() {
@test "back-compat: adding commits" {
for testdir in */; do
cd "$testdir"
run dolt sql -q "insert into abc values (2, 'text', '2020-01-15 20:49:22.28427')"
[ "$status" -eq "0" ]
run dolt add .
[ "$status" -eq "0" ]
run dolt commit -m "Add value during test"
[ "$status" -eq "0" ]
dolt sql -q "insert into abc values (2, 'text', '2020-01-15 20:49:22.28427')"
dolt add .
dolt commit -m "Add value during test"
run dolt sql -q "select * from abc order by pk asc"
[ "$status" -eq "0" ]
[[ "${lines[4]}" =~ " 2 " ]] || false
@@ -96,12 +90,9 @@ teardown() {
[[ "${lines[4]}" =~ " 2020-01-15 20:49:22.28427 " ]] || false
dolt checkout newcolumn
dolt checkout -b testaddcommit
run dolt sql -q "insert into abc values (3, 'text', '2020-01-15 20:49:22.28427', 9241)"
[ "$status" -eq "0" ]
run dolt add .
[ "$status" -eq "0" ]
run dolt commit -m "Add value during test"
[ "$status" -eq "0" ]
dolt sql -q "insert into abc values (3, 'text', '2020-01-15 20:49:22.28427', 9241)"
dolt add .
dolt commit -m "Add value during test"
run dolt sql -q "select * from abc order by pk asc"
[ "$status" -eq "0" ]
[[ "${lines[5]}" =~ " 3 " ]] || false
@@ -141,12 +132,9 @@ teardown() {
[[ "${lines[4]}" =~ " something " ]] || false
[[ "${lines[4]}" =~ " 2020-01-13 20:48:37.13061 " ]] || false
[[ "${lines[4]}" =~ " 1132020 " ]] || false
run dolt conflicts resolve --theirs abc
[ "$status" -eq "0" ]
run dolt add .
[ "$status" -eq "0" ]
run dolt commit -m "Merged newcolumn into conflict"
[ "$status" -eq "0" ]
dolt conflicts resolve --theirs abc
dolt add .
dolt commit -m "Merged newcolumn into conflict"
run dolt sql -q "select * from abc order by pk asc"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false

View File

@@ -20,9 +20,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` BIGINT COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 4611686018427387903);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 4611686018427387903);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 4611686018427387903 " ]] || false
@@ -47,9 +45,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` BIGINT UNSIGNED COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 9223372036854775807);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 9223372036854775807);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 9223372036854775807 " ]] || false
@@ -76,9 +72,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` BINARY(10) COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
@@ -101,9 +95,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` BIT(10) COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 511);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 511);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 511 " ]] || false
@@ -129,15 +121,14 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` BLOB COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
dolt sql -q "UPDATE test SET v='1234567890' WHERE pk=1;"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
}
@test "types: BOOLEAN" {
@@ -151,6 +142,14 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` TINYINT COMMENT 'tag:1'" ]] || false
dolt sql -q "INSERT INTO test VALUES (1, true);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "REPLACE INTO test VALUES (1, false);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 0 " ]] || false
}
@test "types: CHAR(10)" {
@@ -164,9 +163,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` CHAR(10) COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
@@ -189,19 +186,15 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` DATE COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, '2020-02-10 11:12:13.456789');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, '2020-02-10 11:12:13.456789');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 2020-02-10 00:00:00 +0000 UTC " ]] || false
run dolt sql -q "REPLACE INTO test VALUES (1, '1000-01-01 00:00:00');"
[ "$status" -eq "0" ]
dolt sql -q "REPLACE INTO test VALUES (1, '1000-01-01 00:00:00');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1000-01-01 00:00:00 +0000 UTC " ]] || false
run dolt sql -q "REPLACE INTO test VALUES (1, '9999-01-01 23:59:59.999999');"
[ "$status" -eq "0" ]
dolt sql -q "REPLACE INTO test VALUES (1, '9999-01-01 23:59:59.999999');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 9999-01-01 00:00:00 +0000 UTC " ]] || false
@@ -222,19 +215,15 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` DATETIME COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, '2020-02-10 11:12:13.456789');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, '2020-02-10 11:12:13.456789');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 2020-02-10 11:12:13.456789 +0000 UTC " ]] || false
run dolt sql -q "REPLACE INTO test VALUES (1, '1000-01-01 00:00:00');"
[ "$status" -eq "0" ]
dolt sql -q "REPLACE INTO test VALUES (1, '1000-01-01 00:00:00');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1000-01-01 00:00:00 +0000 UTC " ]] || false
run dolt sql -q "REPLACE INTO test VALUES (1, '9999-01-01 23:59:59.999999');"
[ "$status" -eq "0" ]
dolt sql -q "REPLACE INTO test VALUES (1, '9999-01-01 23:59:59.999999');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 9999-01-01 23:59:59.999999 +0000 UTC " ]] || false
@@ -284,9 +273,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` DECIMAL(10, 5) COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 1234.56789);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 1234.56789);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234.56789 " ]] || false
@@ -309,10 +296,12 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` DOUBLE COMMENT 'tag:1'" ]] || false
skip "We can't parse large float values in go-mysql-server yet"
run dolt sql -q "INSERT INTO test VALUES (1, 8.988465674311578540726371186585217839905e+307);"
dolt sql -q "INSERT INTO test VALUES (1, 1.25);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
[[ "${lines[3]}" =~ " 1.25 " ]] || false
skip "We can't parse large float values in go-mysql-server yet"
dolt sql -q "REPLACE INTO test VALUES (1, 8.988465674311578540726371186585217839905e+307);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 8.988465674311578540726371186585217839905e+307 " ]] || false
@@ -338,9 +327,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` ENUM('a','b','c') COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'a');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'a');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " a " ]] || false
@@ -365,10 +352,12 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` FLOAT COMMENT 'tag:1'" ]] || false
skip "We can't parse large float values in go-mysql-server yet"
run dolt sql -q "INSERT INTO test VALUES (1, 170141173319264429905852091742258462720);"
dolt sql -q "INSERT INTO test VALUES (1, 1.25);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
[[ "${lines[3]}" =~ " 1.25 " ]] || false
skip "We can't parse large float values in go-mysql-server yet"
dolt sql -q "REPLACE INTO test VALUES (1, 170141173319264429905852091742258462720);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 170141173319264429905852091742258462720 " ]] || false
@@ -393,9 +382,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` INT COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 1073741823);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 1073741823);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1073741823 " ]] || false
@@ -420,9 +407,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` INT UNSIGNED COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 2147483647);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 2147483647);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 2147483647 " ]] || false
@@ -474,15 +459,14 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` LONGBLOB COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
dolt sql -q "UPDATE test SET v='1234567890' WHERE pk=1;"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
}
@test "types: LONGTEXT" {
@@ -496,15 +480,14 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` LONGTEXT COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
dolt sql -q "UPDATE test SET v='1234567890' WHERE pk=1;"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
}
@test "types: MEDIUMBLOB" {
@@ -519,15 +502,14 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` MEDIUMBLOB COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
dolt sql -q "UPDATE test SET v='1234567890' WHERE pk=1;"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
}
@test "types: MEDIUMINT" {
@@ -541,9 +523,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` MEDIUMINT COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 4194303);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 4194303);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 4194303 " ]] || false
@@ -568,9 +548,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` MEDIUMINT UNSIGNED COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 8388607);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 8388607);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 8388607 " ]] || false
@@ -595,15 +573,14 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` MEDIUMTEXT COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
dolt sql -q "UPDATE test SET v='1234567890' WHERE pk=1;"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
}
@test "types: REAL" {
@@ -631,9 +608,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` SET('a','b','c') COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'b,a');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'b,a');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " a,b " ]] || false
@@ -641,8 +616,7 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " a,b,c " ]] || false
run dolt sql -q "REPLACE INTO test VALUES (1, '');"
[ "$status" -eq "0" ]
dolt sql -q "REPLACE INTO test VALUES (1, '');"
run dolt sql -q "INSERT INTO test VALUES (2, 'd');"
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, 'a,d');"
@@ -660,9 +634,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` SMALLINT COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 16383);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 16383);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 16383 " ]] || false
@@ -687,9 +659,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` SMALLINT UNSIGNED COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 32767);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 32767);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 32767 " ]] || false
@@ -714,15 +684,14 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` TEXT COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
dolt sql -q "UPDATE test SET v='1234567890' WHERE pk=1;"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
}
@test "types: TIME" {
@@ -737,9 +706,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` TIME COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, '11:22:33.444444');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, '11:22:33.444444');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 11:22:33.444444 " ]] || false
@@ -747,13 +714,11 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 11:22:00 " ]] || false
run dolt sql -q "REPLACE INTO test VALUES (1, '850:00:00');"
[ "$status" -eq "0" ]
dolt sql -q "REPLACE INTO test VALUES (1, '850:00:00');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 838:59:59 " ]] || false
run dolt sql -q "REPLACE INTO test VALUES (1, '-850:00:00');"
[ "$status" -eq "0" ]
dolt sql -q "REPLACE INTO test VALUES (1, '-850:00:00');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " -838:59:59 " ]] || false
@@ -770,19 +735,15 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` TIMESTAMP COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, '2020-02-10 11:12:13.456789');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, '2020-02-10 11:12:13.456789');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 2020-02-10 11:12:13.456789 +0000 UTC " ]] || false
run dolt sql -q "REPLACE INTO test VALUES (1, '1970-01-01 00:00:01');"
[ "$status" -eq "0" ]
dolt sql -q "REPLACE INTO test VALUES (1, '1970-01-01 00:00:01');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1970-01-01 00:00:01 +0000 UTC " ]] || false
run dolt sql -q "REPLACE INTO test VALUES (1, '2038-01-19 03:14:07.999999');"
[ "$status" -eq "0" ]
dolt sql -q "REPLACE INTO test VALUES (1, '2038-01-19 03:14:07.999999');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 2038-01-19 03:14:07.999999 +0000 UTC " ]] || false
@@ -804,15 +765,14 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` TINYBLOB COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
dolt sql -q "UPDATE test SET v='1234567890' WHERE pk=1;"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
}
@test "types: TINYINT" {
@@ -826,9 +786,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` TINYINT COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 63);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 63);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 63 " ]] || false
@@ -853,9 +811,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` TINYINT UNSIGNED COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 127);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 127);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 127 " ]] || false
@@ -880,15 +836,14 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` TINYTEXT COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
dolt sql -q "UPDATE test SET v='1234567890' WHERE pk=1;"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
}
@test "types: VARBINARY(10)" {
@@ -903,9 +858,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` VARBINARY(10) COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
@@ -928,9 +881,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` VARCHAR(10) COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
@@ -953,9 +904,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 'abcdefg');"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " abcdefg " ]] || false
@@ -978,9 +927,7 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` YEAR COMMENT 'tag:1'" ]] || false
run dolt sql -q "INSERT INTO test VALUES (1, 1901);"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1 " ]] || false
dolt sql -q "INSERT INTO test VALUES (1, 1901);"
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1901 " ]] || false

View File

@@ -19,8 +19,15 @@ import (
"reflect"
"testing"
"github.com/src-d/go-mysql-server/sql"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"vitess.io/vitess/go/sqltypes"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/dbfactory"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/schema"
"github.com/liquidata-inc/dolt/go/libraries/doltcore/schema/typeinfo"
"github.com/liquidata-inc/dolt/go/store/constants"
"github.com/liquidata-inc/dolt/go/store/types"
)
@@ -81,3 +88,77 @@ func TestJSONMarshalling(t *testing.T) {
t.Error("Value different after marshalling and unmarshalling.")
}
}
func TestTypeInfoMarshalling(t *testing.T) {
//TODO: determine the storage format for BINARY
//TODO: determine the storage format for BLOB
//TODO: determine the storage format for DECIMAL
//TODO: determine the storage format for ENUM
//TODO: determine the storage format for LONGBLOB
//TODO: determine the storage format for MEDIUMBLOB
//TODO: determine the storage format for SET
//TODO: determine the storage format for TIME
//TODO: determine the storage format for TINYBLOB
//TODO: determine the storage format for VARBINARY
sqlTypes := []sql.Type{
sql.Int64, //BIGINT
sql.Uint64, //BIGINT UNSIGNED
//sql.MustCreateBinary(sqltypes.Binary, 10), //BINARY(10)
sql.MustCreateBitType(10), //BIT(10)
//sql.Blob, //BLOB
sql.Boolean, //BOOLEAN
sql.MustCreateStringWithDefaults(sqltypes.Char, 10), //CHAR(10)
sql.Date, //DATE
sql.Datetime, //DATETIME
//sql.MustCreateDecimalType(9, 5), //DECIMAL(9, 5)
sql.Float64, //DOUBLE
//sql.MustCreateEnumType([]string{"a", "b", "c"}, sql.Collation_Default), //ENUM('a','b','c')
sql.Float32, //FLOAT
sql.Int32, //INT
sql.Uint32, //INT UNSIGNED
//sql.LongBlob, //LONGBLOB
sql.LongText, //LONGTEXT
//sql.MediumBlob, //MEDIUMBLOB
sql.Int24, //MEDIUMINT
sql.Uint24, //MEDIUMINT UNSIGNED
sql.MediumText, //MEDIUMTEXT
//sql.MustCreateSetType([]string{"a", "b", "c"}, sql.Collation_Default), //SET('a','b','c')
sql.Int16, //SMALLINT
sql.Uint16, //SMALLINT UNSIGNED
sql.Text, //TEXT
//sql.Time, //TIME
sql.Timestamp, //TIMESTAMP
//sql.TinyBlob, //TINYBLOB
sql.Int8, //TINYINT
sql.Uint8, //TINYINT UNSIGNED
sql.TinyText, //TINYTEXT
//sql.MustCreateBinary(sqltypes.VarBinary, 10), //VARBINARY(10)
sql.MustCreateStringWithDefaults(sqltypes.VarChar, 10), //VARCHAR(10)
sql.MustCreateString(sqltypes.VarChar, 10, sql.Collation_utf8mb3_bin), //VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin
sql.Year, //YEAR
}
for _, sqlType := range sqlTypes {
t.Run(sqlType.String(), func(t *testing.T) {
ti, err := typeinfo.FromSqlType(sqlType)
require.NoError(t, err)
col, err := schema.NewColumnWithTypeInfo("pk", 1, ti, true)
require.NoError(t, err)
colColl, err := schema.NewColCollection(col)
require.NoError(t, err)
originalSch := schema.SchemaFromCols(colColl)
nbf, err := types.GetFormatForVersionString(constants.FormatDefaultString)
require.NoError(t, err)
db, err := dbfactory.MemFactory{}.CreateDB(context.Background(), nbf, nil, nil)
require.NoError(t, err)
val, err := MarshalAsNomsValue(context.Background(), db, originalSch)
require.NoError(t, err)
unmarshalledSch, err := UnmarshalNomsValue(context.Background(), nbf, val)
require.NoError(t, err)
ok, err := schema.SchemasAreEqual(originalSch, unmarshalledSch)
assert.NoError(t, err)
assert.True(t, ok)
})
}
}

View File

@@ -233,21 +233,3 @@ func TestBitParseValue(t *testing.T) {
})
}
}
func generateBitTypes(t *testing.T, numOfTypes uint16) []TypeInfo {
var res []TypeInfo
loop(t, 1, 64, numOfTypes, func(i int64) {
res = append(res, generateBitType(t, uint8(i)))
})
return res
}
func generateBitType(t *testing.T, bits uint8) *bitType {
typ, err := CreateBitTypeFromParams(map[string]string{
bitTypeParam_Bits: strconv.FormatInt(int64(bits), 10),
})
require.NoError(t, err)
realType, ok := typ.(*bitType)
require.True(t, ok)
return realType
}

View File

@@ -16,13 +16,125 @@ package typeinfo
import (
"math"
"strconv"
"testing"
"github.com/src-d/go-mysql-server/sql"
"github.com/stretchr/testify/require"
"vitess.io/vitess/go/sqltypes"
"github.com/liquidata-inc/dolt/go/libraries/utils/mathutil"
)
func generateBitTypes(t *testing.T, numOfTypes uint16) []TypeInfo {
var res []TypeInfo
loop(t, 1, 64, numOfTypes, func(i int64) {
res = append(res, generateBitType(t, uint8(i)))
})
return res
}
func generateBitType(t *testing.T, bits uint8) *bitType {
typ, err := CreateBitTypeFromParams(map[string]string{
bitTypeParam_Bits: strconv.FormatInt(int64(bits), 10),
})
require.NoError(t, err)
realType, ok := typ.(*bitType)
require.True(t, ok)
return realType
}
func generateDecimalTypes(t *testing.T, numOfTypes uint16) []TypeInfo {
var res []TypeInfo
scaleMult := float64(sql.DecimalTypeMaxScale) / sql.DecimalTypeMaxPrecision
loop(t, 1, sql.DecimalTypeMaxPrecision, numOfTypes, func(i int64) {
if i%9 <= 5 {
res = append(res, generateDecimalType(t, i, int64(float64(i)*scaleMult)))
} else {
res = append(res, generateDecimalType(t, i, 0))
}
})
return res
}
func generateDecimalType(t *testing.T, precision int64, scale int64) *decimalType {
typ, err := CreateDecimalTypeFromParams(map[string]string{
decimalTypeParam_Precision: strconv.FormatInt(precision, 10),
decimalTypeParam_Scale: strconv.FormatInt(scale, 10),
})
require.NoError(t, err)
realType, ok := typ.(*decimalType)
require.True(t, ok)
return realType
}
func generateEnumTypes(t *testing.T, numOfTypes int64) []TypeInfo {
res := make([]TypeInfo, numOfTypes)
for i := int64(1); i <= numOfTypes; i++ {
res[i-1] = generateEnumType(t, int(i))
}
return res
}
func generateEnumType(t *testing.T, numOfElements int) *enumType {
require.True(t, numOfElements >= 1 && numOfElements <= sql.EnumTypeMaxElements)
vals := make([]string, numOfElements)
str := make([]byte, 4)
alphabet := "abcdefghijklmnopqrstuvwxyz"
for i := 0; i < numOfElements; i++ {
x := i
for j := 2; j >= 0; j-- {
x /= len(alphabet)
str[j] = alphabet[x%len(alphabet)]
}
str[3] = alphabet[i%len(alphabet)]
vals[i] = string(str)
}
return &enumType{sql.MustCreateEnumType(vals, sql.Collation_Default)}
}
func generateSetTypes(t *testing.T, numOfTypes int64) []TypeInfo {
res := make([]TypeInfo, numOfTypes)
for i := int64(1); i <= numOfTypes; i++ {
res[i-1] = generateSetType(t, int(i))
}
return res
}
func generateSetType(t *testing.T, numOfElements int) *setType {
require.True(t, numOfElements >= 1 && numOfElements <= sql.SetTypeMaxElements)
vals := make([]string, numOfElements)
alphabet := "abcdefghijklmnopqrstuvwxyz"
lenAlphabet := len(alphabet)
for i := 0; i < numOfElements; i++ {
vals[i] = string([]byte{alphabet[(i/lenAlphabet)%lenAlphabet], alphabet[i%lenAlphabet]})
}
return &setType{sql.MustCreateSetType(vals, sql.Collation_Default)}
}
func generateVarBinaryTypes(t *testing.T, numOfTypes uint16) []TypeInfo {
var res []TypeInfo
loop(t, 1, 500, numOfTypes, func(i int64) {
pad := false
if i%2 == 0 {
pad = true
}
res = append(res, generateVarBinaryType(t, i, pad))
})
return res
}
func generateVarBinaryType(t *testing.T, length int64, pad bool) *varBinaryType {
require.True(t, length > 0)
if pad {
t, err := sql.CreateBinary(sqltypes.Binary, length)
if err == nil {
return &varBinaryType{t}
}
}
return &varBinaryType{sql.MustCreateBinary(sqltypes.VarBinary, length)}
}
func loop(t *testing.T, start int64, endInclusive int64, numOfSteps uint16, loopedFunc func(int64)) {
require.True(t, endInclusive > start)
maxNumOfSteps := endInclusive - start + 1

View File

@@ -1,50 +0,0 @@
// Copyright 2020 Liquidata, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package typeinfo
import (
"strconv"
"testing"
"github.com/src-d/go-mysql-server/sql"
"github.com/stretchr/testify/require"
)
//TODO: add some basic tests once the storage format has been decided
func generateDecimalTypes(t *testing.T, numOfTypes uint16) []TypeInfo {
var res []TypeInfo
scaleMult := float64(sql.DecimalTypeMaxScale) / sql.DecimalTypeMaxPrecision
loop(t, 1, sql.DecimalTypeMaxPrecision, numOfTypes, func(i int64) {
if i%9 <= 5 {
res = append(res, generateDecimalType(t, i, int64(float64(i)*scaleMult)))
} else {
res = append(res, generateDecimalType(t, i, 0))
}
})
return res
}
func generateDecimalType(t *testing.T, precision int64, scale int64) *decimalType {
typ, err := CreateDecimalTypeFromParams(map[string]string{
decimalTypeParam_Precision: strconv.FormatInt(precision, 10),
decimalTypeParam_Scale: strconv.FormatInt(scale, 10),
})
require.NoError(t, err)
realType, ok := typ.(*decimalType)
require.True(t, ok)
return realType
}

View File

@@ -1,49 +0,0 @@
// Copyright 2020 Liquidata, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package typeinfo
import (
"testing"
"github.com/src-d/go-mysql-server/sql"
"github.com/stretchr/testify/require"
)
//TODO: add some basic tests once the storage format has been decided
func generateEnumTypes(t *testing.T, numOfTypes int64) []TypeInfo {
res := make([]TypeInfo, numOfTypes)
for i := int64(1); i <= numOfTypes; i++ {
res[i-1] = generateEnumType(t, int(i))
}
return res
}
func generateEnumType(t *testing.T, numOfElements int) *enumType {
require.True(t, numOfElements >= 1 && numOfElements <= sql.EnumTypeMaxElements)
vals := make([]string, numOfElements)
str := make([]byte, 4)
alphabet := "abcdefghijklmnopqrstuvwxyz"
for i := 0; i < numOfElements; i++ {
x := i
for j := 2; j >= 0; j-- {
x /= len(alphabet)
str[j] = alphabet[x%len(alphabet)]
}
str[3] = alphabet[i%len(alphabet)]
vals[i] = string(str)
}
return &enumType{sql.MustCreateEnumType(vals, sql.Collation_Default)}
}

View File

@@ -1,43 +0,0 @@
// Copyright 2020 Liquidata, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package typeinfo
import (
"testing"
"github.com/src-d/go-mysql-server/sql"
"github.com/stretchr/testify/require"
)
//TODO: add some basic tests once the storage format has been decided
func generateSetTypes(t *testing.T, numOfTypes int64) []TypeInfo {
res := make([]TypeInfo, numOfTypes)
for i := int64(1); i <= numOfTypes; i++ {
res[i-1] = generateSetType(t, int(i))
}
return res
}
func generateSetType(t *testing.T, numOfElements int) *setType {
require.True(t, numOfElements >= 1 && numOfElements <= sql.SetTypeMaxElements)
vals := make([]string, numOfElements)
alphabet := "abcdefghijklmnopqrstuvwxyz"
lenAlphabet := len(alphabet)
for i := 0; i < numOfElements; i++ {
vals[i] = string([]byte{alphabet[(i/lenAlphabet)%lenAlphabet], alphabet[i%lenAlphabet]})
}
return &setType{sql.MustCreateSetType(vals, sql.Collation_Default)}
}

View File

@@ -1,17 +0,0 @@
// Copyright 2020 Liquidata, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package typeinfo
//TODO: add some basic tests once the storage format has been decided

View File

@@ -68,6 +68,9 @@ func verifyTypeInfoArrays(t *testing.T, tiArrays [][]TypeInfo, vaArrays [][]type
// delete any types that should not be tested
delete(seenTypeInfos, UnknownTypeIdentifier)
delete(seenTypeInfos, TupleTypeIdentifier)
//TODO: determine the storage format for DecimalType and VarBinaryType
delete(seenTypeInfos, DecimalTypeIdentifier)
delete(seenTypeInfos, VarBinaryTypeIdentifier)
for _, tiArray := range tiArrays {
// no row should be empty
require.True(t, len(tiArray) > 0, `length of array "%v" should be greater than zero`, len(tiArray))
@@ -103,11 +106,6 @@ func verifyTypeInfoArrays(t *testing.T, tiArrays [][]TypeInfo, vaArrays [][]type
func testTypeInfoConvertRoundTrip(t *testing.T, tiArrays [][]TypeInfo, vaArrays [][]types.Value) {
for rowIndex, tiArray := range tiArrays {
t.Run(tiArray[0].GetTypeIdentifier().String(), func(t *testing.T) {
//TODO: determine the storage format for DecimalType
//TODO: determine the storage format for VarBinaryType
if tiArray[0].GetTypeIdentifier() == DecimalTypeIdentifier || tiArray[0].GetTypeIdentifier() == VarBinaryTypeIdentifier {
t.Skipf(`"%v" not yet persisted, thus no need to fix tests`, tiArray[0].GetTypeIdentifier().String())
}
for _, ti := range tiArray {
atLeastOneValid := false
t.Run(ti.String(), func(t *testing.T) {
@@ -208,11 +206,6 @@ func testTypeInfoForeignKindHandling(t *testing.T, tiArrays [][]TypeInfo, vaArra
func testTypeInfoFormatParseRoundTrip(t *testing.T, tiArrays [][]TypeInfo, vaArrays [][]types.Value) {
for rowIndex, tiArray := range tiArrays {
t.Run(tiArray[0].GetTypeIdentifier().String(), func(t *testing.T) {
//TODO: determine the storage format for DecimalType
//TODO: determine the storage format for VarBinaryType
if tiArray[0].GetTypeIdentifier() == DecimalTypeIdentifier || tiArray[0].GetTypeIdentifier() == VarBinaryTypeIdentifier {
t.Skipf(`"%v" not yet persisted, thus no need to fix tests`, tiArray[0].GetTypeIdentifier().String())
}
for _, ti := range tiArray {
atLeastOneValid := false
t.Run(ti.String(), func(t *testing.T) {
@@ -337,7 +330,7 @@ func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) {
generateBitTypes(t, 16),
{BoolType},
{DateType, DatetimeType, TimestampType},
generateDecimalTypes(t, 16),
//generateDecimalTypes(t, 16),
generateEnumTypes(t, 16),
{Float32Type, Float64Type},
{InlineBlobType},
@@ -346,9 +339,9 @@ func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) {
{TimeType},
{Uint8Type, Uint16Type, Uint24Type, Uint32Type, Uint64Type},
{UuidType},
append(generateVarBinaryTypes(t, 12),
&varBinaryType{sql.TinyBlob}, &varBinaryType{sql.Blob},
&varBinaryType{sql.MediumBlob}, &varBinaryType{sql.LongBlob}),
//append(generateVarBinaryTypes(t, 12),
// &varBinaryType{sql.TinyBlob}, &varBinaryType{sql.Blob},
// &varBinaryType{sql.MediumBlob}, &varBinaryType{sql.LongBlob}),
append(generateVarStringTypes(t, 12),
&varStringType{sql.CreateTinyText(sql.Collation_Default)}, &varStringType{sql.CreateText(sql.Collation_Default)},
&varStringType{sql.CreateMediumText(sql.Collation_Default)}, &varStringType{sql.CreateLongText(sql.Collation_Default)}),
@@ -362,8 +355,8 @@ func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) {
types.Timestamp(time.Date(2000, 2, 28, 14, 38, 43, 583395000, time.UTC)),
types.Timestamp(time.Date(2038, 1, 19, 3, 14, 7, 999999000, time.UTC)),
types.Timestamp(time.Date(9999, 12, 31, 23, 59, 59, 999999000, time.UTC))},
{types.String("1"), types.String("-1.5"), types.String("4723245"), //Decimal
types.String("8923583.125"), types.String("1198728394234798423466321.27349757")},
//{types.String("1"), types.String("-1.5"), types.String("4723245"), //Decimal
// types.String("8923583.125"), types.String("1198728394234798423466321.27349757")},
{types.String("aaaa"), types.String("aaaa,aaac"), types.String("aaag"), types.String("aaab,aaad,aaaf"), types.String("aaag,aaah")}, //Enum
{types.Float(1.0), types.Float(65513.75), types.Float(4293902592), types.Float(4.58E71), types.Float(7.172E285)}, //Float
{types.InlineBlob{0}, types.InlineBlob{21}, types.InlineBlob{1, 17}, types.InlineBlob{72, 42}, types.InlineBlob{21, 122, 236}}, //InlineBlob
@@ -372,8 +365,8 @@ func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) {
{types.String("00:00:00"), types.String("00:00:01"), types.String("00:01:53"), types.String("68:36:59"), types.String("127:27:10.485214")}, //Time
{types.Uint(20), types.Uint(275), types.Uint(328395), types.Uint(630257298), types.Uint(93897259874)}, //Uint
{types.UUID{3}, types.UUID{3, 13}, types.UUID{128, 238, 82, 12}, types.UUID{31, 54, 23, 13, 63, 43}, types.UUID{83, 64, 21, 14, 42, 6, 35, 7, 54, 234, 6, 32, 1, 4, 2, 4}}, //Uuid
{types.String([]byte{1}), types.String([]byte{42, 52}), types.String([]byte{84, 32, 13, 63, 12, 86}), //VarBinary
types.String([]byte{1, 32, 235, 64, 32, 23, 45, 76}), types.String([]byte{123, 234, 34, 223, 76, 35, 32, 12, 84, 26, 15, 34, 65, 86, 45, 23, 43, 12, 76, 154, 234, 76, 34})},
//{types.String([]byte{1}), types.String([]byte{42, 52}), types.String([]byte{84, 32, 13, 63, 12, 86}), //VarBinary
// types.String([]byte{1, 32, 235, 64, 32, 23, 45, 76}), types.String([]byte{123, 234, 34, 223, 76, 35, 32, 12, 84, 26, 15, 34, 65, 86, 45, 23, 43, 12, 76, 154, 234, 76, 34})},
{types.String(""), types.String("a"), types.String("abc"), //VarString
types.String("abcdefghijklmnopqrstuvwxyz"), types.String("هذا هو بعض نماذج النص التي أستخدمها لاختبار عناصر")},
{types.Int(1901), types.Int(1950), types.Int(2000), types.Int(2080), types.Int(2155)}, //Year

View File

@@ -1,48 +0,0 @@
// Copyright 2020 Liquidata, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package typeinfo
import (
"testing"
"github.com/src-d/go-mysql-server/sql"
"github.com/stretchr/testify/require"
"vitess.io/vitess/go/sqltypes"
)
//TODO: add some basic tests once the storage format has been decided
func generateVarBinaryTypes(t *testing.T, numOfTypes uint16) []TypeInfo {
var res []TypeInfo
loop(t, 1, 500, numOfTypes, func(i int64) {
pad := false
if i%2 == 0 {
pad = true
}
res = append(res, generateVarBinaryType(t, i, pad))
})
return res
}
func generateVarBinaryType(t *testing.T, length int64, pad bool) *varBinaryType {
require.True(t, length > 0)
if pad {
t, err := sql.CreateBinary(sqltypes.Binary, length)
if err == nil {
return &varBinaryType{t}
}
}
return &varBinaryType{sql.MustCreateBinary(sqltypes.VarBinary, length)}
}