提交 6e271d45 authored 作者: Thomas Mueller's avatar Thomas Mueller

Shell tool: the built-in command "distinct" has been removed (use the SQL…

Shell tool: the built-in command "distinct" has been removed (use the SQL statements "show tables" / "show columns from tableName" instead). The result set formatting has been improved.
上级 8e266637
...@@ -56,6 +56,14 @@ public class TestShell extends TestBase { ...@@ -56,6 +56,14 @@ public class TestShell extends TestBase {
assertContains(s, "HI"); assertContains(s, "HI");
assertContains(s, "Hello World"); assertContains(s, "Hello World");
assertContains(s, "(1 row, "); assertContains(s, "(1 row, ");
shell = new Shell();
buff = new ByteArrayOutputStream();
shell.setOut(new PrintStream(buff));
shell.runTool("-help");
s = new String(buff.toByteArray());
assertContains(s, "Interactive command line tool to access a database using JDBC.");
test(true); test(true);
test(false); test(false);
} }
...@@ -106,7 +114,6 @@ public class TestShell extends TestBase { ...@@ -106,7 +114,6 @@ public class TestShell extends TestBase {
read("help or ?"); read("help or ?");
read("list"); read("list");
read("maxwidth"); read("maxwidth");
read("describe");
read("autocommit"); read("autocommit");
read("history"); read("history");
read("quit or exit"); read("quit or exit");
...@@ -133,6 +140,17 @@ public class TestShell extends TestBase { ...@@ -133,6 +140,17 @@ public class TestShell extends TestBase {
read("x"); read("x");
read("(data is partially truncated)"); read("(data is partially truncated)");
read("(1 row,"); read("(1 row,");
testOut.println("select x, 's' s from system_range(0, 10001);");
read("sql> X | S");
for (int i = 0; i < 10000; i++) {
read((i + " ").substring(0, 4) + " | s");
}
for (int i = 10000; i <= 10001; i++) {
read((i + " ").substring(0, 5) + " | s");
}
read("(10002 rows,");
testOut.println("select error;"); testOut.println("select error;");
read("sql> Error:"); read("sql> Error:");
if (read("").startsWith("Column \"ERROR\" not found")) { if (read("").startsWith("Column \"ERROR\" not found")) {
...@@ -142,10 +160,24 @@ public class TestShell extends TestBase { ...@@ -142,10 +160,24 @@ public class TestShell extends TestBase {
read("sql> ...>"); read("sql> ...>");
testOut.println("insert into test values(1, 'Hello');"); testOut.println("insert into test values(1, 'Hello');");
read("sql>"); read("sql>");
testOut.println("select * from test;"); testOut.println("select null n, * from test;");
read("sql> ID"); read("sql> N | ID | NAME");
read("1 "); read("null | 1 | Hello");
read("(1 row,");
// test history
for (int i = 0; i < 30; i++) {
testOut.println("select " + i + " ID from test;");
read("sql> ID");
read("" + i);
read("(1 row,");
}
testOut.println("20");
read("sql> select 10 ID from test");
read("ID");
read("10");
read("(1 row,"); read("(1 row,");
testOut.println("maxwidth"); testOut.println("maxwidth");
read("sql> Usage: maxwidth <integer value>"); read("sql> Usage: maxwidth <integer value>");
read("Maximum column width is now 100"); read("Maximum column width is now 100");
...@@ -158,28 +190,29 @@ public class TestShell extends TestBase { ...@@ -158,28 +190,29 @@ public class TestShell extends TestBase {
read("sql> Autocommit is now false"); read("sql> Autocommit is now false");
testOut.println("autocommit true"); testOut.println("autocommit true");
read("sql> Autocommit is now true"); read("sql> Autocommit is now true");
testOut.println("describe");
read("sql> Usage: describe [<schema name>.]<table name>");
read("Schema");
while (read("").startsWith("INFORMATION_SCHEMA")) {
// ignore
}
testOut.println("describe test");
read("sql> Column Name");
read("ID");
read("NAME");
testOut.println("describe public.test");
read("sql> Column Name");
read("ID");
read("NAME");
testOut.println("\n;"); testOut.println("\n;");
read("sql>"); read("sql>");
testOut.println("list"); testOut.println("list");
read("sql> Result list mode is now on"); read("sql> Result list mode is now on");
testOut.println("select 1 a, 2 b;");
read("sql> A: 1"); testOut.println("select 1 first, 2 second;");
read("B: 2"); read("sql> FIRST : 1");
read("SECOND: 2");
read("(1 row, "); read("(1 row, ");
testOut.println("select x from system_range(1, 3);");
read("sql> X: 1");
read("");
read("X: 2");
read("");
read("X: 3");
read("(3 rows, ");
testOut.println("select x, 2 as y from system_range(1, 3) where 1 = 0;");
read("sql> X");
read("Y");
read("(0 rows, ");
testOut.println("list"); testOut.println("list");
read("sql> Result list mode is now off"); read("sql> Result list mode is now off");
testOut.println("help"); testOut.println("help");
...@@ -187,7 +220,6 @@ public class TestShell extends TestBase { ...@@ -187,7 +220,6 @@ public class TestShell extends TestBase {
read("help or ?"); read("help or ?");
read("list"); read("list");
read("maxwidth"); read("maxwidth");
read("describe");
read("autocommit"); read("autocommit");
read("history"); read("history");
read("quit or exit"); read("quit or exit");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论