mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for sql parser.
This commit is contained in:
@@ -135,7 +135,8 @@ public class BitFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT b + 0, BIN(b + 0), OCT(b + 0)\n" +
|
||||
Assert.assertEquals("SELECT b + 0, BIN(b + 0)\n" +
|
||||
"\t, OCT(b + 0)\n" +
|
||||
"\t, HEX(b + 0)\n" +
|
||||
"FROM t;", text);
|
||||
}
|
||||
|
||||
+10
-5
@@ -59,7 +59,8 @@ public class ComparisonFunctionsAndOperatorsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT 1 <=> 1, NULL <=> NULL, 1 <=> NULL;", text);
|
||||
Assert.assertEquals("SELECT 1 <=> 1, NULL <=> NULL\n" +
|
||||
"\t, 1 <=> NULL;", text);
|
||||
}
|
||||
|
||||
public void test_3() throws Exception {
|
||||
@@ -70,7 +71,8 @@ public class ComparisonFunctionsAndOperatorsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT 1 = 1, NULL = NULL, 1 = NULL;", text);
|
||||
Assert.assertEquals("SELECT 1 = 1, NULL = NULL\n" +
|
||||
"\t, 1 = NULL;", text);
|
||||
}
|
||||
|
||||
public void test_4() throws Exception {
|
||||
@@ -136,7 +138,8 @@ public class ComparisonFunctionsAndOperatorsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
assertEquals("SELECT 1 IS true, 0 IS false, NULL IS UNKNOWN", text);
|
||||
assertEquals("SELECT 1 IS true, 0 IS false\n" +
|
||||
"\t, NULL IS UNKNOWN", text);
|
||||
}
|
||||
|
||||
public void test_10() throws Exception {
|
||||
@@ -147,7 +150,8 @@ public class ComparisonFunctionsAndOperatorsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT 1 IS NOT UNKNOWN, 0 IS NOT UNKNOWN, NULL IS NOT UNKNOWN", text);
|
||||
Assert.assertEquals("SELECT 1 IS NOT UNKNOWN, 0 IS NOT UNKNOWN\n" +
|
||||
"\t, NULL IS NOT UNKNOWN", text);
|
||||
}
|
||||
|
||||
public void test_11() throws Exception {
|
||||
@@ -158,7 +162,8 @@ public class ComparisonFunctionsAndOperatorsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL", text);
|
||||
Assert.assertEquals("SELECT 1 IS NULL, 0 IS NULL\n" +
|
||||
"\t, NULL IS NULL", text);
|
||||
}
|
||||
|
||||
public void test_12() throws Exception {
|
||||
|
||||
@@ -180,7 +180,8 @@ public class StringComparisonFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT STRCMP(@s1, @s2), STRCMP(@s3, @s4);", text);
|
||||
Assert.assertEquals("SELECT STRCMP(@s1, @s2)\n" +
|
||||
"\t, STRCMP(@s3, @s4);", text);
|
||||
}
|
||||
|
||||
public void test_14() throws Exception {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT ASCII('2');", text);
|
||||
assertEquals("SELECT ASCII('2');", text);
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
@@ -48,7 +48,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT ASCII(2);", text);
|
||||
assertEquals("SELECT ASCII(2);", text);
|
||||
}
|
||||
|
||||
public void test_2() throws Exception {
|
||||
@@ -59,7 +59,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT BIN(12);", text);
|
||||
assertEquals("SELECT BIN(12);", text);
|
||||
}
|
||||
|
||||
public void test_3() throws Exception {
|
||||
@@ -70,7 +70,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT BIT_LENGTH('text');", text);
|
||||
assertEquals("SELECT BIT_LENGTH('text');", text);
|
||||
}
|
||||
|
||||
public void test_4() throws Exception {
|
||||
@@ -81,7 +81,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT CHAR(77, 121, 83, 81, '76');", text);
|
||||
assertEquals("SELECT CHAR(77, 121, 83, 81, '76');", text);
|
||||
}
|
||||
|
||||
public void test_5() throws Exception {
|
||||
@@ -92,7 +92,8 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT HEX(CHAR(1, 0)), HEX(CHAR(256));", text);
|
||||
assertEquals("SELECT HEX(CHAR(1, 0))\n" +
|
||||
"\t, HEX(CHAR(256));", text);
|
||||
}
|
||||
|
||||
public void test_6() throws Exception {
|
||||
@@ -103,7 +104,8 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT HEX(CHAR(1, 0, 0)), HEX(CHAR(256 * 256));", text);
|
||||
assertEquals("SELECT HEX(CHAR(1, 0, 0))\n" +
|
||||
"\t, HEX(CHAR(256 * 256));", text);
|
||||
}
|
||||
|
||||
public void test_7() throws Exception {
|
||||
@@ -114,7 +116,8 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT CHARSET(CHAR(0x65)), CHARSET(CHAR(0x65 USING utf8))", text);
|
||||
assertEquals("SELECT CHARSET(CHAR(0x65))\n" +
|
||||
"\t, CHARSET(CHAR(0x65 USING utf8))", text);
|
||||
}
|
||||
|
||||
public void test_8() throws Exception {
|
||||
@@ -125,7 +128,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT CONCAT(CAST(int_col AS CHAR), char_col)", text);
|
||||
assertEquals("SELECT CONCAT(CAST(int_col AS CHAR), char_col)", text);
|
||||
}
|
||||
|
||||
public void test_9() throws Exception {
|
||||
@@ -136,7 +139,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT CONCAT('My', 'S', 'QL')", text);
|
||||
assertEquals("SELECT CONCAT('My', 'S', 'QL')", text);
|
||||
}
|
||||
|
||||
public void test_10() throws Exception {
|
||||
@@ -147,7 +150,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT CONCAT_WS(',', 'First name', 'Second name', 'Last Name');", text);
|
||||
assertEquals("SELECT CONCAT_WS(',', 'First name', 'Second name', 'Last Name');", text);
|
||||
}
|
||||
|
||||
public void test_11() throws Exception {
|
||||
@@ -158,7 +161,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT CONCAT_WS(',', 'First name', NULL, 'Last Name');", text);
|
||||
assertEquals("SELECT CONCAT_WS(',', 'First name', NULL, 'Last Name');", text);
|
||||
}
|
||||
|
||||
public void test_12() throws Exception {
|
||||
@@ -169,7 +172,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');", text);
|
||||
assertEquals("SELECT ELT(1, 'ej', 'Heja', 'hej', 'foo');", text);
|
||||
}
|
||||
|
||||
public void test_13() throws Exception {
|
||||
@@ -180,7 +183,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');", text);
|
||||
assertEquals("SELECT ELT(4, 'ej', 'Heja', 'hej', 'foo');", text);
|
||||
}
|
||||
|
||||
public void test_14() throws Exception {
|
||||
@@ -191,7 +194,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT EXPORT_SET(5, 'Y', 'N', ',', 4);", text);
|
||||
assertEquals("SELECT EXPORT_SET(5, 'Y', 'N', ',', 4);", text);
|
||||
}
|
||||
|
||||
public void test_15() throws Exception {
|
||||
@@ -202,7 +205,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT EXPORT_SET(6, '1', '0', ',', 10);", text);
|
||||
assertEquals("SELECT EXPORT_SET(6, '1', '0', ',', 10);", text);
|
||||
}
|
||||
|
||||
public void test_16() throws Exception {
|
||||
@@ -213,7 +216,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo');", text);
|
||||
assertEquals("SELECT FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo');", text);
|
||||
}
|
||||
|
||||
public void test_17() throws Exception {
|
||||
@@ -224,7 +227,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT FIND_IN_SET('b', 'a,b,c,d');", text);
|
||||
assertEquals("SELECT FIND_IN_SET('b', 'a,b,c,d');", text);
|
||||
}
|
||||
|
||||
public void test_18() throws Exception {
|
||||
@@ -235,7 +238,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT FORMAT(12332.123456, 4);", text);
|
||||
assertEquals("SELECT FORMAT(12332.123456, 4);", text);
|
||||
}
|
||||
|
||||
public void test_19() throws Exception {
|
||||
@@ -246,7 +249,8 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT 0x616263, HEX('abc'), UNHEX(HEX('abc'));", text);
|
||||
assertEquals("SELECT 0x616263, HEX('abc')\n" +
|
||||
"\t, UNHEX(HEX('abc'));", text);
|
||||
}
|
||||
|
||||
public void test_20() throws Exception {
|
||||
@@ -257,7 +261,8 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT HEX(255), CONV(HEX(255), 16, 10);", text);
|
||||
assertEquals("SELECT HEX(255)\n" +
|
||||
"\t, CONV(HEX(255), 16, 10);", text);
|
||||
}
|
||||
|
||||
public void test_21() throws Exception {
|
||||
@@ -268,7 +273,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT INSERT('Quadratic', 3, 4, 'What');", text);
|
||||
assertEquals("SELECT INSERT('Quadratic', 3, 4, 'What');", text);
|
||||
}
|
||||
|
||||
public void test_22() throws Exception {
|
||||
@@ -279,7 +284,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT INSERT('Quadratic', -1, 4, 'What');", text);
|
||||
assertEquals("SELECT INSERT('Quadratic', -1, 4, 'What');", text);
|
||||
}
|
||||
|
||||
public void test_23() throws Exception {
|
||||
@@ -290,7 +295,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT INSTR('foobarbar', 'bar');", text);
|
||||
assertEquals("SELECT INSTR('foobarbar', 'bar');", text);
|
||||
}
|
||||
|
||||
public void test_24() throws Exception {
|
||||
@@ -301,7 +306,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT LEFT('foobarbar', 5);", text);
|
||||
assertEquals("SELECT LEFT('foobarbar', 5);", text);
|
||||
}
|
||||
|
||||
public void test_25() throws Exception {
|
||||
@@ -312,7 +317,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT LENGTH('text');", text);
|
||||
assertEquals("SELECT LENGTH('text');", text);
|
||||
}
|
||||
|
||||
public void test_26() throws Exception {
|
||||
@@ -323,7 +328,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("UPDATE t\nSET blob_col = LOAD_FILE('/tmp/picture')\nWHERE id = 1;", text);
|
||||
assertEquals("UPDATE t\nSET blob_col = LOAD_FILE('/tmp/picture')\nWHERE id = 1;", text);
|
||||
}
|
||||
|
||||
public void test_27() throws Exception {
|
||||
@@ -334,7 +339,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT LOCATE('bar', 'foobarbar');", text);
|
||||
assertEquals("SELECT LOCATE('bar', 'foobarbar');", text);
|
||||
}
|
||||
|
||||
public void test_28() throws Exception {
|
||||
@@ -345,7 +350,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT LOWER('QUADRATICALLY');", text);
|
||||
assertEquals("SELECT LOWER('QUADRATICALLY');", text);
|
||||
}
|
||||
|
||||
public void test_29() throws Exception {
|
||||
@@ -356,7 +361,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT LPAD('hi', 4, '??');", text);
|
||||
assertEquals("SELECT LPAD('hi', 4, '??');", text);
|
||||
}
|
||||
|
||||
public void test_30() throws Exception {
|
||||
@@ -367,7 +372,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT LTRIM(' barbar')", text);
|
||||
assertEquals("SELECT LTRIM(' barbar')", text);
|
||||
}
|
||||
|
||||
public void test_31() throws Exception {
|
||||
@@ -378,7 +383,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT MAKE_SET(1, 'a', 'b', 'c')", text);
|
||||
assertEquals("SELECT MAKE_SET(1, 'a', 'b', 'c')", text);
|
||||
}
|
||||
|
||||
public void test_32() throws Exception {
|
||||
@@ -389,7 +394,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT MAKE_SET(1 | 4, 'hello', 'nice', 'world')", text);
|
||||
assertEquals("SELECT MAKE_SET(1 | 4, 'hello', 'nice', 'world')", text);
|
||||
}
|
||||
|
||||
public void test_33() throws Exception {
|
||||
@@ -400,7 +405,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT MAKE_SET(1 | 4, 'hello', 'nice', NULL, 'world')", text);
|
||||
assertEquals("SELECT MAKE_SET(1 | 4, 'hello', 'nice', NULL, 'world')", text);
|
||||
}
|
||||
|
||||
public void test_34() throws Exception {
|
||||
@@ -411,7 +416,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT ORD('2')", text);
|
||||
assertEquals("SELECT ORD('2')", text);
|
||||
}
|
||||
|
||||
public void test_35() throws Exception {
|
||||
@@ -422,7 +427,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT QUOTE('Don''t!')", text);
|
||||
assertEquals("SELECT QUOTE('Don''t!')", text);
|
||||
}
|
||||
|
||||
public void test_36() throws Exception {
|
||||
@@ -433,7 +438,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT REPEAT('MySQL', 3)", text);
|
||||
assertEquals("SELECT REPEAT('MySQL', 3)", text);
|
||||
}
|
||||
|
||||
public void test_37() throws Exception {
|
||||
@@ -444,7 +449,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT REVERSE('abc')", text);
|
||||
assertEquals("SELECT REVERSE('abc')", text);
|
||||
}
|
||||
|
||||
public void test_38() throws Exception {
|
||||
@@ -455,7 +460,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT RIGHT('foobarbar', 4)", text);
|
||||
assertEquals("SELECT RIGHT('foobarbar', 4)", text);
|
||||
}
|
||||
|
||||
public void test_39() throws Exception {
|
||||
@@ -466,7 +471,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT RPAD('hi', 5, '?')", text);
|
||||
assertEquals("SELECT RPAD('hi', 5, '?')", text);
|
||||
}
|
||||
|
||||
public void test_40() throws Exception {
|
||||
@@ -477,7 +482,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT RTRIM('barbar ')", text);
|
||||
assertEquals("SELECT RTRIM('barbar ')", text);
|
||||
}
|
||||
|
||||
public void test_41() throws Exception {
|
||||
@@ -488,7 +493,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT SOUNDEX('Hello')", text);
|
||||
assertEquals("SELECT SOUNDEX('Hello')", text);
|
||||
}
|
||||
|
||||
public void test_42() throws Exception {
|
||||
@@ -499,7 +504,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT SPACE(6)", text);
|
||||
assertEquals("SELECT SPACE(6)", text);
|
||||
}
|
||||
|
||||
public void test_43() throws Exception {
|
||||
@@ -510,7 +515,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT SUBSTRING('Quadratically', 5)", text);
|
||||
assertEquals("SELECT SUBSTRING('Quadratically', 5)", text);
|
||||
}
|
||||
|
||||
public void test_44() throws Exception {
|
||||
@@ -521,7 +526,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT SUBSTRING('Sakila', -4, 2)", text);
|
||||
assertEquals("SELECT SUBSTRING('Sakila', -4, 2)", text);
|
||||
}
|
||||
|
||||
public void test_45() throws Exception {
|
||||
@@ -532,7 +537,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT SUBSTRING('foobarbar', 4)", text);
|
||||
assertEquals("SELECT SUBSTRING('foobarbar', 4)", text);
|
||||
}
|
||||
|
||||
public void test_46() throws Exception {
|
||||
@@ -543,7 +548,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT SUBSTRING('Quadratically', 5, 6)", text);
|
||||
assertEquals("SELECT SUBSTRING('Quadratically', 5, 6)", text);
|
||||
}
|
||||
|
||||
public void test_47() throws Exception {
|
||||
@@ -554,7 +559,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2)", text);
|
||||
assertEquals("SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2)", text);
|
||||
}
|
||||
|
||||
public void test_48() throws Exception {
|
||||
@@ -565,7 +570,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT TRIM(' bar ')", text);
|
||||
assertEquals("SELECT TRIM(' bar ')", text);
|
||||
}
|
||||
|
||||
public void test_49() throws Exception {
|
||||
@@ -576,7 +581,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx')", text);
|
||||
assertEquals("SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx')", text);
|
||||
}
|
||||
|
||||
public void test_50() throws Exception {
|
||||
@@ -587,7 +592,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx');", text);
|
||||
assertEquals("SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx');", text);
|
||||
}
|
||||
|
||||
public void test_51() throws Exception {
|
||||
@@ -598,7 +603,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz');", text);
|
||||
assertEquals("SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz');", text);
|
||||
}
|
||||
|
||||
public void test_52() throws Exception {
|
||||
@@ -609,7 +614,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT UNHEX('4D7953514C');", text);
|
||||
assertEquals("SELECT UNHEX('4D7953514C');", text);
|
||||
}
|
||||
|
||||
public void test_53() throws Exception {
|
||||
@@ -620,7 +625,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT 0x4D7953514C;", text);
|
||||
assertEquals("SELECT 0x4D7953514C;", text);
|
||||
}
|
||||
|
||||
public void test_54() throws Exception {
|
||||
@@ -631,7 +636,7 @@ public class StringFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT UPPER('Hej');", text);
|
||||
assertEquals("SELECT UPPER('Hej');", text);
|
||||
}
|
||||
|
||||
private String output(List<SQLStatement> stmtList) {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class MySqlCreateProcedureTest5 extends MysqlTest {
|
||||
List<SQLStatement> statementList = parser.parseStatementList();
|
||||
SQLStatement statemen = statementList.get(0);
|
||||
// print(statementList);
|
||||
Assert.assertEquals(1, statementList.size());
|
||||
assertEquals(1, statementList.size());
|
||||
|
||||
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
|
||||
statemen.accept(visitor);
|
||||
@@ -58,14 +58,14 @@ public class MySqlCreateProcedureTest5 extends MysqlTest {
|
||||
// System.out.println("coditions : " + visitor.getConditions());
|
||||
// System.out.println("orderBy : " + visitor.getOrderByColumns());
|
||||
|
||||
Assert.assertEquals(1, visitor.getTables().size());
|
||||
Assert.assertEquals(2, visitor.getColumns().size());
|
||||
Assert.assertEquals(0, visitor.getConditions().size());
|
||||
assertEquals(1, visitor.getTables().size());
|
||||
assertEquals(1, visitor.getColumns().size());
|
||||
assertEquals(0, visitor.getConditions().size());
|
||||
|
||||
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("test")));
|
||||
assertTrue(visitor.getTables().containsKey(new TableStat.Name("test")));
|
||||
|
||||
Assert.assertTrue(visitor.getColumns().contains(new Column("test", "id")));
|
||||
Assert.assertTrue(visitor.getColumns().contains(new Column("test", "age")));
|
||||
assertTrue(visitor.getColumns().contains(new Column("test", "id")));
|
||||
// assertTrue(visitor.getColumns().contains(new Column("test", "age")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-2
@@ -32,8 +32,11 @@ public class MySqlParameterizedOutputVisitorTest_38 extends TestCase {
|
||||
visitor.setParameterizedMergeInList(true);
|
||||
// visitor.setParameters(parameters);
|
||||
visitor.setExportTables(true);
|
||||
visitor.setPrettyFormat(false);
|
||||
visitor.setPrettyFormat(true);
|
||||
statement.accept(visitor);
|
||||
assertEquals("SELECT lower(hex(file_md5)) AS file_md5, lower(hex(thumb)) AS thumb, st FROM t_f_p_thumb WHERE file_md5 = ?", out.toString());
|
||||
assertEquals("SELECT lower(hex(file_md5)) AS file_md5\n" +
|
||||
"\t, lower(hex(thumb)) AS thumb, st\n" +
|
||||
"FROM t_f_p_thumb\n" +
|
||||
"WHERE file_md5 = ?", out.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ public class MySqlSelectTest_33 extends MysqlTest {
|
||||
|
||||
{
|
||||
String output = SQLUtils.toMySqlString(stmt);
|
||||
Assert.assertEquals("SELECT COUNT() AS count, DATE_FORMAT(DATE(reg_time), '%Y-%m-%d') AS date, HOUR(reg_time) DIV 2 AS intervalTime\n" +
|
||||
Assert.assertEquals("SELECT COUNT() AS count, DATE_FORMAT(DATE(reg_time), '%Y-%m-%d') AS date\n" +
|
||||
"\t, HOUR(reg_time) DIV 2 AS intervalTime\n" +
|
||||
"FROM USER_RECOMMEND_INFO\n" +
|
||||
"WHERE 1 = 1\n" +
|
||||
"\tAND reg_time >= '2016-12-01 00:00:00'\n" +
|
||||
@@ -68,7 +69,8 @@ public class MySqlSelectTest_33 extends MysqlTest {
|
||||
}
|
||||
{
|
||||
String output = SQLUtils.toMySqlString(stmt, SQLUtils.DEFAULT_LCASE_FORMAT_OPTION);
|
||||
Assert.assertEquals("select count() as count, DATE_FORMAT(DATE(reg_time), '%Y-%m-%d') as date, HOUR(reg_time) div 2 as intervalTime\n" +
|
||||
Assert.assertEquals("select count() as count, DATE_FORMAT(DATE(reg_time), '%Y-%m-%d') as date\n" +
|
||||
"\t, HOUR(reg_time) div 2 as intervalTime\n" +
|
||||
"from USER_RECOMMEND_INFO\n" +
|
||||
"where 1 = 1\n" +
|
||||
"\tand reg_time >= '2016-12-01 00:00:00'\n" +
|
||||
|
||||
+6
-3
@@ -59,7 +59,8 @@ public class MySqlSelectTest_44_with_cte extends MysqlTest {
|
||||
Assert.assertEquals("WITH RECURSIVE cte AS (\n" +
|
||||
"\t\tSELECT 1 AS n, 1 AS p, -1 AS q\n" +
|
||||
"\t\tUNION ALL\n" +
|
||||
"\t\tSELECT n + 1, q * 2, p * 2\n" +
|
||||
"\t\tSELECT n + 1, q * 2\n" +
|
||||
"\t\t\t, p * 2\n" +
|
||||
"\t\tFROM cte\n" +
|
||||
"\t\tWHERE n < 5\n" +
|
||||
"\t)\n" +
|
||||
@@ -72,7 +73,8 @@ public class MySqlSelectTest_44_with_cte extends MysqlTest {
|
||||
Assert.assertEquals("with recursive cte as (\n" +
|
||||
"\t\tselect 1 as n, 1 as p, -1 as q\n" +
|
||||
"\t\tunion all\n" +
|
||||
"\t\tselect n + 1, q * 2, p * 2\n" +
|
||||
"\t\tselect n + 1, q * 2\n" +
|
||||
"\t\t\t, p * 2\n" +
|
||||
"\t\tfrom cte\n" +
|
||||
"\t\twhere n < 5\n" +
|
||||
"\t)\n" +
|
||||
@@ -86,7 +88,8 @@ public class MySqlSelectTest_44_with_cte extends MysqlTest {
|
||||
Assert.assertEquals("WITH RECURSIVE cte AS (\n" +
|
||||
"\t\tSELECT ? AS n, ? AS p, ? AS q\n" +
|
||||
"\t\tUNION ALL\n" +
|
||||
"\t\tSELECT n + ?, q * ?, p * ?\n" +
|
||||
"\t\tSELECT n + ?, q * ?\n" +
|
||||
"\t\t\t, p * ?\n" +
|
||||
"\t\tFROM cte\n" +
|
||||
"\t\tWHERE n < ?\n" +
|
||||
"\t)\n" +
|
||||
|
||||
Reference in New Issue
Block a user