add bats tests for information schema tables (#5225)

This commit is contained in:
jennifersp
2023-01-27 08:48:08 -08:00
committed by GitHub
parent 3039ba33b5
commit a6278667b7
10 changed files with 373 additions and 12 deletions

View File

@@ -107,6 +107,11 @@ SQL
[[ "${lines[4]}" =~ ' 1 ' ]] || false
[[ "${lines[5]}" =~ ' 2 ' ]] || false
[[ "${lines[6]}" =~ ' 3 ' ]] || false
# check information_schema.VIEWS table
# TODO: view_definition should be "select `mybin`.`my_users`.`id` AS `id` from `mybin`.`my_users` order by `mybin`.`my_users`.`id`"
run dolt sql -q "select * from information_schema.VIEWS;" -r csv
[[ "$output" =~ "def,dolt_repo_$$,my_users_view,select id from my_users order by id asc,NONE,YES,root@localhost,DEFINER,utf8mb4,utf8mb4_0900_bin" ]] || false
}
@test "create-views: view referencing table selects values inserted after it was created" {

View File

@@ -129,6 +129,27 @@ SQL
dolt sql -q 'select * from objects'
dolt add .
dolt commit -m 'update 1'
# check information_schema.CHECK_CONSTRAINTS table
run dolt sql -q "select constraint_name, table_name, column_name, ordinal_position, position_in_unique_constraint, referenced_table_name, referenced_column_name from information_schema.KEY_COLUMN_USAGE;" -r csv
[[ "$output" =~ "PRIMARY,colors,id,1,,," ]] || false
[[ "$output" =~ "PRIMARY,materials,id,1,,," ]] || false
[[ "$output" =~ "jb6i5huc,materials,color,1,1,colors,color" ]] || false
[[ "$output" =~ "PRIMARY,objects,id,1,,," ]] || false
[[ "$output" =~ "i5lsjmoo,objects,color,1,1,materials,color" ]] || false
[[ "$output" =~ "i5lsjmoo,objects,material,2,2,materials,material" ]] || false
[[ "$output" =~ "PRIMARY,child,id,1,,," ]] || false
[[ "$output" =~ "PRIMARY,parent,id,1,,," ]] || false
# check information_schema.TABLE_CONSTRAINTS table
run dolt sql -q "select * from information_schema.TABLE_CONSTRAINTS where table_name = 'materials';" -r csv
[[ "$output" =~ "def,dolt_repo_$$,PRIMARY,dolt_repo_$$,materials,PRIMARY KEY,YES" ]] || false
[[ "$output" =~ "def,dolt_repo_$$,jb6i5huc,dolt_repo_$$,materials,FOREIGN KEY,YES" ]] || false
# check information_schema.TABLE_CONSTRAINTS_EXTENSIONS table
run dolt sql -q "select constraint_name from information_schema.TABLE_CONSTRAINTS_EXTENSIONS where table_name = 'materials';" -r csv
[[ "$output" =~ "PRIMARY" ]] || false
[[ "$output" =~ "color_mat_index" ]] || false
}
@test "foreign-keys: ALTER TABLE Single Named FOREIGN KEY" {
@@ -732,6 +753,10 @@ SQL
run dolt sql -q "DELETE FROM one;"
[ "$status" -eq "1" ]
[[ "$output" =~ "violation" ]] || false
# check information_schema.REFERENTIAL_CONSTRAINTS table
run dolt sql -q "select constraint_name, unique_constraint_name, match_option, update_rule, delete_rule, table_name, referenced_table_name from information_schema.REFERENTIAL_CONSTRAINTS;" -r csv
[[ "$output" =~ "fk_name_1,,NONE,RESTRICT,RESTRICT,two,one" ]] || false
}
@test "foreign-keys: SQL no reference options" {

View File

@@ -20,19 +20,27 @@ teardown() {
}
@test "sql-charsets-collations: define charset and collation on a column" {
dolt sql -q "create table german1 (c char(10) CHARACTER SET latin1 COLLATE latin1_german1_ci)"
run dolt sql -q "show create table german1";
[ $status -eq 0 ]
[[ $output =~ "CHARACTER SET latin1" ]] || false
[[ $output =~ "COLLATE latin1_german1_ci" ]] || false
dolt sql -q "create table german1 (c char(10) CHARACTER SET latin1 COLLATE latin1_german1_ci)"
run dolt sql -q "show create table german1";
[ $status -eq 0 ]
[[ $output =~ "CHARACTER SET latin1" ]] || false
[[ $output =~ "COLLATE latin1_german1_ci" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select table_name, column_name, character_set_name, collation_name from information_schema.COLUMNS;" -r csv
[[ "$output" =~ "german1,c,latin1,latin1_german1_ci" ]] || false
}
@test "sql-charsets-collations: define charset and collation on a table" {
dolt sql -q "create table german1 (c char(10)) CHARACTER SET latin1 COLLATE latin1_german1_ci"
run dolt sql -q "show create table german1";
[ $status -eq 0 ]
[[ $output =~ "CHARACTER SET latin1" ]] || false
[[ $output =~ "COLLATE latin1_german1_ci" ]] || false
dolt sql -q "create table german1 (c char(10)) CHARACTER SET latin1 COLLATE latin1_german1_ci"
run dolt sql -q "show create table german1";
[ $status -eq 0 ]
[[ $output =~ "CHARACTER SET latin1" ]] || false
[[ $output =~ "COLLATE latin1_german1_ci" ]] || false
# check information_schema.TABLES table
run dolt sql -q "select table_name, table_type, table_collation from information_schema.TABLES where table_name = 'german1';" -r csv
[[ "$output" =~ "german1,BASE TABLE,latin1_german1_ci" ]] || false
}
@test "sql-charsets-collations: define charset and collation on a database" {

View File

@@ -78,6 +78,10 @@ SQL
echo $output
[[ "$output" =~ "CHECK" ]] || false
[[ "$output" =~ "`c1` > 3" ]] || false
# check information_schema.CHECK_CONSTRAINTS table
run dolt sql -q "select constraint_catalog, constraint_name, check_clause from information_schema.CHECK_CONSTRAINTS;" -r csv
[[ "$output" =~ "def,chk_eq3jn5ra,(c1 > 3)" ]] || false
}
@test "sql-check-constraints: check constraints survive renaming a column" {

View File

@@ -313,4 +313,10 @@ SQL
[[ "$output" =~ "dolt_repo_$$" ]] || false
[[ "$output" =~ "information_schema" ]] || false
[[ "$output" =~ "metabase" ]] || false
cd metabase
# check information_schema.SCHEMATA table
run dolt sql -q "select * from information_schema.SCHEMATA where schema_name = 'metabase';" -r csv
[[ "$output" =~ "def,metabase,utf8mb4,utf8mb4_unicode_ci,,NO" ]] || false
cd ..
}

View File

@@ -613,7 +613,11 @@ behavior:
run dolt sql-client -P $PORT -u dolt --use-db test_db -q "show tables"
[ $status -eq 0 ]
[[ $output =~ t1 ]] || false
# check information_schema.SCHEMA_PRIVILEGES table
run dolt sql-client -P $PORT -u dolt --use-db test_db -q "select * from information_schema.SCHEMA_PRIVILEGES;"
[[ "$output" =~ "| 'test'@'%' | def | test_db | SELECT | NO |" ]] || false
# Revoke works as expected
dolt sql-client -P $PORT -u dolt --use-db test_db -q "revoke select on test_db.* from test"
run dolt sql-client -P $PORT -u test --use-db test_db -q "show tables"
@@ -627,7 +631,20 @@ behavior:
[ $status -eq 0 ]
[[ $output =~ t1 ]] || false
# check information_schema.SCHEMA_PRIVILEGES table
run dolt sql-client -P $PORT -u dolt --use-db test_db -q "select * from information_schema.SCHEMA_PRIVILEGES;"
[[ "$output" =~ "| 'test'@'127.0.0.1' | def | test_db | SELECT | NO |" ]] || false
dolt sql-client -P $PORT -u dolt --use-db test_db -q "grant update on test_db.t1 to test@'127.0.0.1'"
# check information_schema.TABLE_PRIVILEGES table
run dolt sql-client -P $PORT -u dolt --use-db test_db -q "select * from information_schema.TABLE_PRIVILEGES;"
[[ "$output" =~ "| 'test'@'127.0.0.1' | def | test_db | t1 | UPDATE | NO |" ]] || false
dolt sql-client -P $PORT -u dolt --use-db test_db -q "grant insert on *.* to test@'127.0.0.1'"
# check information_schema.USER_PRIVILEGES table
run dolt sql-client -P $PORT -u test -H 127.0.0.1 --use-db test_db -q "select * from information_schema.USER_PRIVILEGES;"
[[ "$output" =~ "| 'test'@'127.0.0.1' | def | INSERT | NO |" ]] || false
dolt sql-client -P $PORT -u dolt --use-db test_db -q "drop user test@'127.0.0.1'"
dolt sql-client -P $PORT -u dolt --use-db test_db -q "create user test@'10.10.10.10'"
dolt sql-client -P $PORT -u dolt --use-db test_db -q "grant select on test_db.* to test@'10.10.10.10'"

View File

@@ -211,6 +211,10 @@ teardown() {
run dolt sql -q "SELECT ST_ASWKT(p) FROM pt"
[[ ! "$output" =~ "POINT(1 2)" ]] || false
# check information_schema.ST_GEOMETRY_COLUMNS table
run dolt sql -q "select * from information_schema.ST_GEOMETRY_COLUMNS;" -r csv
[[ "$output" =~ "pt,p,\"\",0,point" ]] || false
}
@test "sql-spatial-types: SRID defined in column definition in ALTER TABLE" {

View File

@@ -879,6 +879,22 @@ SQL
[[ "$output" =~ foo ]] || false
[[ "$output" =~ bar ]] || false
[ "${#lines[@]}" -eq 8 ]
# check information_schema.STATISTICS table
# TODO: caridnality here are all 0's as it's not supported yet
run dolt sql -q "select * from information_schema.STATISTICS;" -r csv
[[ "$output" =~ "has_datetimes,0,dolt_repo_$$,PRIMARY,1,pk,A,0,,,\"\",BTREE,\"\",\"\",YES," ]] || false
[[ "$output" =~ "one_pk,0,dolt_repo_$$,PRIMARY,1,pk,A,0,,,\"\",BTREE,\"\",\"\",YES," ]] || false
[[ "$output" =~ "two_pk,0,dolt_repo_$$,PRIMARY,1,pk1,A,0,,,\"\",BTREE,\"\",\"\",YES," ]] || false
[[ "$output" =~ "two_pk,0,dolt_repo_$$,PRIMARY,2,pk2,A,0,,,\"\",BTREE,\"\",\"\",YES," ]] || false
skip "ALTER VIEW is unsupported"
# check cardinality on information_schema.STATISTICS table
run dolt sql -q "select table_name, column_name, cardinality from information_schema.STATISTICS;" -r csv
[[ "$output" =~ "has_datetimes,pk,1" ]] || false
[[ "$output" =~ "one_pk,pk,4" ]] || false
[[ "$output" =~ "two_pk,pk1,2" ]] || false
[[ "$output" =~ "two_pk,pk2,4" ]] || false
}
@test "sql: AS OF queries" {
@@ -2400,6 +2416,26 @@ SQL
[[ "${#lines[@]}" = "2" ]] || false
}
@test "sql: check info_schema routines and parameters tables for stored procedures" {
dolt sql <<SQL
CREATE TABLE inventory (item_id int primary key, shelf_id int, items varchar(100));
CREATE PROCEDURE in_stock (IN p_id INT, OUT p_count INT) SELECT COUNT(*) FROM inventory WHERE shelf_id = p_id INTO p_count;
SQL
# check information_schema.PARAMETERS table
run dolt sql -q "select specific_name, ordinal_position, parameter_mode, parameter_name, data_type, dtd_identifier, routine_type from information_schema.PARAMETERS;" -r csv
[[ "$output" =~ "in_stock,1,IN,p_id,int,int,PROCEDURE" ]] || false
[[ "$output" =~ "in_stock,2,OUT,p_count,int,int,PROCEDURE" ]] || false
# check information_schema.ROUTINES table
run dolt sql -q "select specific_name, routine_name, routine_type, routine_body, routine_definition from information_schema.ROUTINES;" -r csv
[[ "$output" =~ "in_stock,in_stock,PROCEDURE,SQL,SELECT COUNT(*) FROM inventory WHERE shelf_id = p_id INTO p_count" ]] || false
# check information_schema.ROUTINES table
run dolt sql -q "select specific_name, is_deterministic, sql_data_access, security_type, routine_comment, definer, character_set_client, collation_connection, database_collation from information_schema.ROUTINES;" -r csv
[[ "$output" =~ "in_stock,NO,CONTAINS SQL,DEFINER,\"\",\"\",utf8mb4,utf8mb4_0900_bin,utf8mb4_0900_bin" ]] || false
}
@test "sql: active_branch() func" {
run dolt sql -q 'select active_branch()' -r csv
[ $status -eq 0 ]

View File

@@ -113,6 +113,10 @@ SQL
[[ "$output" =~ "2,3" ]] || false
[[ "$output" =~ "3,4" ]] || false
[[ "${#lines[@]}" = "4" ]] || false
# check information_schema.TRIGGERS table
run dolt sql -q "select trigger_name, event_manipulation, event_object_table, action_order, action_condition, action_statement, action_timing, definer, character_set_client, collation_connection, database_collation from information_schema.TRIGGERS;" -r csv
[[ "$output" =~ "trigger1,INSERT,test,1,,SET new.v1 = new.v1 + 1,BEFORE,root@localhost,utf8mb4,utf8mb4_0900_bin,utf8mb4_0900_bin" ]] || false
}
@test "triggers: Writing directly into dolt_schemas" {

View File

@@ -56,6 +56,11 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -40000000000000000000);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test';" -r csv
[[ "$output" =~ 'test,pk,1,,NO,bigint,,,19,0,,,,bigint,PRI,"","insert,references,select,update","","",' ]] || false
[[ "$output" =~ 'test,v,2,,YES,bigint,,,19,0,,,,bigint,"","","insert,references,select,update","","",' ]] || false
}
@test "types: BIGINT UNSIGNED" {
@@ -88,6 +93,10 @@ DELIM
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -1);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,bigint,,,20,0,,,,bigint unsigned,"","","insert,references,select,update","","",' ]] || false
}
@test "types: BINARY(10)" {
@@ -111,6 +120,10 @@ SQL
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
run dolt sql -q "INSERT INTO test VALUES (2, '12345678901');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,binary,10,10,,,,,,binary(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: BIT(10)" {
@@ -136,6 +149,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -1);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,bit,,,10,,,,,bit(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: BLOB" {
@@ -157,6 +174,10 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,blob,65535,65535,,,,,,blob,"","","insert,references,select,update","","",' ]] || false
}
@test "types: BOOL" {
@@ -170,6 +191,11 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` tinyint" ]] || false
# check information_schema.COLUMNS table
# TODO : 'column_type' should be 'tinyint(1)'
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,tinyint,,,3,0,,,,tinyint,"","","insert,references,select,update","","",' ]] || false
}
@test "types: BOOLEAN" {
@@ -191,6 +217,11 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 0 " ]] || false
# check information_schema.COLUMNS table
# TODO : 'column_type' should be 'tinyint(1)'
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,tinyint,,,3,0,,,,tinyint,"","","insert,references,select,update","","",' ]] || false
}
@test "types: CHAR(10)" {
@@ -214,6 +245,10 @@ SQL
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
run dolt sql -q "INSERT INTO test VALUES (2, '12345678901');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,char,10,40,,,,utf8mb4,utf8mb4_0900_bin,char(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: CHARACTER(10)" {
@@ -227,6 +262,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` char(10)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,char,10,40,,,,utf8mb4,utf8mb4_0900_bin,char(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: CHARACTER VARYING(10)" {
@@ -240,6 +279,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` varchar(10)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,varchar,10,40,,,,utf8mb4,utf8mb4_0900_bin,varchar(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: DATE" {
@@ -285,6 +328,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, '10000-01-01 00:00:00');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,date,,,,,,,,date,"","","insert,references,select,update","","",' ]] || false
}
@test "types: DATETIME" {
@@ -330,6 +377,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, '10000-01-01 00:00:00');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,datetime,,,,,0,,,datetime,"","","insert,references,select,update","","",' ]] || false
}
@test "types: DEC" {
@@ -343,6 +394,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(10,0)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,10,0,,,,"decimal(10,0)","","","insert,references,select,update","","",' ]] || false
}
@test "types: DEC(9)" {
@@ -356,6 +411,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(9,0)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,9,0,,,,"decimal(9,0)","","","insert,references,select,update","","",' ]] || false
}
@test "types: DEC(9,5)" {
@@ -369,6 +428,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(9,5)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,9,5,,,,"decimal(9,5)","","","insert,references,select,update","","",' ]] || false
}
@test "types: DECIMAL" {
@@ -382,6 +445,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(10,0)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,10,0,,,,"decimal(10,0)","","","insert,references,select,update","","",' ]] || false
}
@test "types: DECIMAL(9)" {
@@ -395,6 +462,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(9,0)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,9,0,,,,"decimal(9,0)","","","insert,references,select,update","","",' ]] || false
}
@test "types: DECIMAL(9,5)" {
@@ -418,6 +489,10 @@ SQL
[[ "${lines[3]}" =~ " 2469.13578 " ]] || false
run dolt sql -q "INSERT INTO test VALUES (2, 10000);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,9,5,,,,"decimal(9,5)","","","insert,references,select,update","","",' ]] || false
}
@test "types: DOUBLE" {
@@ -452,6 +527,10 @@ pk,v
DELIM
run dolt table import -u test double.csv
[ "$status" -ne "0" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,double,,,22,,,,,double,"","","insert,references,select,update","","",' ]] || false
}
@test "types: DOUBLE PRECISION" {
@@ -465,6 +544,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` double" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,double,,,22,,,,,double,"","","insert,references,select,update","","",' ]] || false
}
@test "types: Double with precision and scale correctly gets interpreted as a decimal" {
@@ -489,6 +572,10 @@ SQL
[ "$status" -eq "0" ]
[[ "$output" =~ "column_name, numeric_scale, numeric_precision" ]] || false
[[ "$output" =~ "pk,5,2" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,double,,,5,1,,,,double(5,1),"","","insert,references,select,update","","",' ]] || false
}
@test "types: ENUM('a','b','c')" {
@@ -514,6 +601,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, '');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ "test,v,2,,YES,enum,1,4,,,,utf8mb4,utf8mb4_0900_bin,\"enum('a','b','c')\",\"\",\"\",\"insert,references,select,update\",\"\",\"\"," ]] || false
}
@test "types: FIXED" {
@@ -527,6 +618,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(10,0)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,10,0,,,,"decimal(10,0)","","","insert,references,select,update","","",' ]] || false
}
@test "types: FIXED(9)" {
@@ -540,6 +635,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(9,0)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,9,0,,,,"decimal(9,0)","","","insert,references,select,update","","",' ]] || false
}
@test "types: FIXED(9,5)" {
@@ -553,6 +652,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(9,5)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,9,5,,,,"decimal(9,5)","","","insert,references,select,update","","",' ]] || false
}
@test "types: FLOAT" {
@@ -596,6 +699,10 @@ pk,v
DELIM
run dolt table import -u test float.csv
[ "$status" -ne "0" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,float,,,12,,,,,float,"","","insert,references,select,update","","",' ]] || false
}
@test "types: INT" {
@@ -621,6 +728,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -2147483649);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,int,,,10,0,,,,int,"","","insert,references,select,update","","",' ]] || false
}
@test "types: INT UNSIGNED" {
@@ -646,6 +757,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -1);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,int,,,10,0,,,,int unsigned,"","","insert,references,select,update","","",' ]] || false
}
@test "types: INTEGER" {
@@ -659,6 +774,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` int" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,int,,,10,0,,,,int,"","","insert,references,select,update","","",' ]] || false
}
@test "types: INTEGER UNSIGNED" {
@@ -672,6 +791,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` int unsigned" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,int,,,10,0,,,,int unsigned,"","","insert,references,select,update","","",' ]] || false
}
@test "types: LONG" {
@@ -685,6 +808,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` mediumtext" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,mediumtext,4194303,16777215,,,,utf8mb4,utf8mb4_0900_bin,mediumtext,"","","insert,references,select,update","","",' ]] || false
}
@test "types: LONG VARCHAR" {
@@ -698,6 +825,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` mediumtext" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,mediumtext,4194303,16777215,,,,utf8mb4,utf8mb4_0900_bin,mediumtext,"","","insert,references,select,update","","",' ]] || false
}
@test "types: LONGBLOB" {
@@ -719,6 +850,10 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,longblob,4294967295,4294967295,,,,,,longblob,"","","insert,references,select,update","","",' ]] || false
}
@test "types: LONGTEXT" {
@@ -763,6 +898,10 @@ SQL
[[ "$output" =~ "5,01" ]] || false
[[ "$output" =~ "6,0" ]] || false
[[ "${#lines[@]}" = "6" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,longtext,1073741823,4294967295,,,,utf8mb4,utf8mb4_0900_bin,longtext,"","","insert,references,select,update","","",' ]] || false
}
@test "types: MEDIUMBLOB" {
@@ -784,6 +923,10 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,mediumblob,16777215,16777215,,,,,,mediumblob,"","","insert,references,select,update","","",' ]] || false
}
@test "types: MEDIUMINT" {
@@ -809,6 +952,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -8388609);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,mediumint,,,7,0,,,,mediumint,"","","insert,references,select,update","","",' ]] || false
}
@test "types: MEDIUMINT UNSIGNED" {
@@ -834,6 +981,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -1);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,mediumint,,,7,0,,,,mediumint unsigned,"","","insert,references,select,update","","",' ]] || false
}
@test "types: MEDIUMTEXT" {
@@ -855,6 +1006,10 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,mediumtext,4194303,16777215,,,,utf8mb4,utf8mb4_0900_bin,mediumtext,"","","insert,references,select,update","","",' ]] || false
}
@test "types: NATIONAL CHAR(10)" {
@@ -868,6 +1023,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` char(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,char,10,30,,,,utf8mb3,utf8mb3_general_ci,char(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: NATIONAL CHARACTER(10)" {
@@ -881,6 +1040,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` char(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,char,10,30,,,,utf8mb3,utf8mb3_general_ci,char(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: NATIONAL CHARACTER VARYING(10)" {
@@ -894,6 +1057,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,varchar,10,30,,,,utf8mb3,utf8mb3_general_ci,varchar(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: NATIONAL VARCHAR(10)" {
@@ -907,6 +1074,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,varchar,10,30,,,,utf8mb3,utf8mb3_general_ci,varchar(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: NCHAR(10)" {
@@ -920,6 +1091,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` char(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,char,10,30,,,,utf8mb3,utf8mb3_general_ci,char(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: NVARCHAR(10)" {
@@ -933,6 +1108,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,varchar,10,30,,,,utf8mb3,utf8mb3_general_ci,varchar(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: NUMERIC" {
@@ -946,6 +1125,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(10,0)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,10,0,,,,"decimal(10,0)","","","insert,references,select,update","","",' ]] || false
}
@test "types: NUMERIC(9)" {
@@ -959,6 +1142,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(9,0)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,9,0,,,,"decimal(9,0)","","","insert,references,select,update","","",' ]] || false
}
@test "types: NUMERIC(9,5)" {
@@ -972,6 +1159,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` decimal(9,5)" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,decimal,,,9,5,,,,"decimal(9,5)","","","insert,references,select,update","","",' ]] || false
}
@test "types: REAL" {
@@ -985,6 +1176,10 @@ SQL
run dolt schema show
[ "$status" -eq "0" ]
[[ "$output" =~ "\`v\` double" ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,double,,,22,,,,,double,"","","insert,references,select,update","","",' ]] || false
}
@test "types: SET('a','b','c')" {
@@ -1011,6 +1206,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, 'a,d');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ "test,v,2,,YES,set,5,20,,,,utf8mb4,utf8mb4_0900_bin,\"set('a','b','c')\",\"\",\"\",\"insert,references,select,update\",\"\",\"\"," ]] || false
}
@test "types: SMALLINT" {
@@ -1036,6 +1235,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -32769);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,smallint,,,5,0,,,,smallint,"","","insert,references,select,update","","",' ]] || false
}
@test "types: SMALLINT UNSIGNED" {
@@ -1061,6 +1264,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -1);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,smallint,,,5,0,,,,smallint unsigned,"","","insert,references,select,update","","",' ]] || false
}
@test "types: TEXT" {
@@ -1082,6 +1289,10 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,text,16383,65535,,,,utf8mb4,utf8mb4_0900_bin,text,"","","insert,references,select,update","","",' ]] || false
}
@test "types: TIME" {
@@ -1111,6 +1322,11 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " -838:59:59 " ]] || false
# check information_schema.COLUMNS table
# TODO: time precision is not supported, this type's 'datetime_precision' and 'column_type' should be '0', 'time' respectively.
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,time,,,,,6,,,time(6),"","","insert,references,select,update","","",' ]] || false
}
@test "types: TIMESTAMP" {
@@ -1140,6 +1356,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, '2038-01-19 03:14:08');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,timestamp,,,,,0,,,timestamp,"","","insert,references,select,update","","",' ]] || false
}
@test "types: TINYBLOB" {
@@ -1161,6 +1381,10 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,tinyblob,255,255,,,,,,tinyblob,"","","insert,references,select,update","","",' ]] || false
}
@test "types: TINYINT" {
@@ -1186,6 +1410,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -129);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,tinyint,,,3,0,,,,tinyint,"","","insert,references,select,update","","",' ]] || false
}
@test "types: TINYINT UNSIGNED" {
@@ -1211,6 +1439,10 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, -1);"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,tinyint,,,3,0,,,,tinyint unsigned,"","","insert,references,select,update","","",' ]] || false
}
@test "types: TINYTEXT" {
@@ -1232,6 +1464,10 @@ SQL
run dolt sql -q "SELECT * FROM test"
[ "$status" -eq "0" ]
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,tinytext,63,255,,,,utf8mb4,utf8mb4_0900_bin,tinytext,"","","insert,references,select,update","","",' ]] || false
}
@test "types: VARBINARY(10)" {
@@ -1255,6 +1491,10 @@ SQL
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
run dolt sql -q "INSERT INTO test VALUES (2, '12345678901');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,varbinary,10,10,,,,,,varbinary(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: VARCHAR(10)" {
@@ -1278,6 +1518,10 @@ SQL
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
run dolt sql -q "INSERT INTO test VALUES (2, '12345678901');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,varchar,10,40,,,,utf8mb4,utf8mb4_0900_bin,varchar(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: VARCHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" {
@@ -1301,6 +1545,10 @@ SQL
[[ "${lines[3]}" =~ " 1234567890 " ]] || false
run dolt sql -q "INSERT INTO test VALUES (2, '12345678901');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,varchar,10,40,,,,utf32,utf32_general_ci,varchar(10),"","","insert,references,select,update","","",' ]] || false
}
@test "types: YEAR" {
@@ -1326,4 +1574,8 @@ SQL
[ "$status" -eq "1" ]
run dolt sql -q "INSERT INTO test VALUES (2, '2156');"
[ "$status" -eq "1" ]
# check information_schema.COLUMNS table
run dolt sql -q "select * from information_schema.COLUMNS where table_name = 'test' and column_name = 'v';" -r csv
[[ "$output" =~ 'test,v,2,,YES,year,,,,,,,,year,"","","insert,references,select,update","","",' ]] || false
}