mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-19 14:30:43 +00:00
test: sqlness test for insert default (#873)
* test: sqlness test for insert default Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * empty line Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * add more sqls Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix typos Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * update test according to typo fix Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
@@ -308,7 +308,7 @@ pub enum Error {
|
||||
},
|
||||
|
||||
#[snafu(display(
|
||||
"No valid default value can be build automatically, column: {}",
|
||||
"No valid default value can be built automatically, column: {}",
|
||||
column,
|
||||
))]
|
||||
ColumnNoneDefaultValue {
|
||||
|
||||
@@ -391,7 +391,7 @@ pub enum Error {
|
||||
},
|
||||
|
||||
#[snafu(display(
|
||||
"No valid default value can be build automatically, column: {}",
|
||||
"No valid default value can be built automatically, column: {}",
|
||||
column,
|
||||
))]
|
||||
ColumnNoneDefaultValue {
|
||||
|
||||
66
tests/cases/standalone/insert/insert_default.result
Normal file
66
tests/cases/standalone/insert/insert_default.result
Normal file
@@ -0,0 +1,66 @@
|
||||
CREATE TABLE test1 (i INTEGER, j BIGINT TIME INDEX, k STRING DEFAULT 'blabla');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO test1 VALUES (DEFAULT);
|
||||
|
||||
Error: 1004(InvalidArguments), Columns and values number mismatch, columns: 3, values: 1
|
||||
|
||||
INSERT INTO test1 VALUES (DEFAULT, DEFAULT, DEFAULT);
|
||||
|
||||
Error: 1004(InvalidArguments), No valid default value can be built automatically, column: j
|
||||
|
||||
INSERT INTO test1 VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT);
|
||||
|
||||
Error: 1004(InvalidArguments), Columns and values number mismatch, columns: 3, values: 4
|
||||
|
||||
INSERT INTO test1 VALUES (DEFAULT, 1, DEFAULT), (default, 2, default), (DeFaUlT, 3, DeFaUlT), (dEfAuLt, 4, dEfAuLt);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
SELECT * FROM test1;
|
||||
|
||||
+---+---+--------+
|
||||
| i | j | k |
|
||||
+---+---+--------+
|
||||
| | 1 | blabla |
|
||||
| | 2 | blabla |
|
||||
| | 3 | blabla |
|
||||
| | 4 | blabla |
|
||||
+---+---+--------+
|
||||
|
||||
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX DEFAULT CURRENT_TIMESTAMP, k STRING DEFAULT 'blabla');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO test2 VALUES (1,1,'a'), (default, 2, default), (3,3,'b'), (default, 4, default), (5, 5, 'c');
|
||||
|
||||
Affected Rows: 5
|
||||
|
||||
INSERT INTO test2 VALUES (6, 6, default), (7, 7, 'd'), (default, 8, 'e');
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
SELECT * FROM test2;
|
||||
|
||||
+---+---+--------+
|
||||
| i | j | k |
|
||||
+---+---+--------+
|
||||
| 1 | 1 | a |
|
||||
| | 2 | blabla |
|
||||
| 3 | 3 | b |
|
||||
| | 4 | blabla |
|
||||
| 5 | 5 | c |
|
||||
| 6 | 6 | blabla |
|
||||
| 7 | 7 | d |
|
||||
| | 8 | e |
|
||||
+---+---+--------+
|
||||
|
||||
DROP TABLE test1;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
DROP TABLE test2;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
22
tests/cases/standalone/insert/insert_default.sql
Normal file
22
tests/cases/standalone/insert/insert_default.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
CREATE TABLE test1 (i INTEGER, j BIGINT TIME INDEX, k STRING DEFAULT 'blabla');
|
||||
|
||||
INSERT INTO test1 VALUES (DEFAULT);
|
||||
|
||||
INSERT INTO test1 VALUES (DEFAULT, DEFAULT, DEFAULT);
|
||||
|
||||
INSERT INTO test1 VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT);
|
||||
|
||||
INSERT INTO test1 VALUES (DEFAULT, 1, DEFAULT), (default, 2, default), (DeFaUlT, 3, DeFaUlT), (dEfAuLt, 4, dEfAuLt);
|
||||
|
||||
SELECT * FROM test1;
|
||||
|
||||
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX DEFAULT CURRENT_TIMESTAMP, k STRING DEFAULT 'blabla');
|
||||
|
||||
INSERT INTO test2 VALUES (1,1,'a'), (default, 2, default), (3,3,'b'), (default, 4, default), (5, 5, 'c');
|
||||
|
||||
INSERT INTO test2 VALUES (6, 6, default), (7, 7, 'd'), (default, 8, 'e');
|
||||
|
||||
SELECT * FROM test2;
|
||||
|
||||
DROP TABLE test1;
|
||||
DROP TABLE test2;
|
||||
Reference in New Issue
Block a user