mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
support oceanbase dbtype
Signed-off-by: hongwei yi hongweiyi@hotmail.com 1. add oceanbase/oceanbase_oracle dbtype 2. update some dbtype recognition usages
This commit is contained in:
@@ -82,5 +82,14 @@ public class WallSelectLimitTest_2 extends TestCase {
|
||||
assertEquals("SELECT *\n" +
|
||||
"FROM t\n" +
|
||||
"WHERE ROWNUM <= 10", resultSql);
|
||||
|
||||
sql = PagerUtils.limit("select * from t", JdbcConstants.OCEANBASE_ORACLE, 0, 10);
|
||||
provider = new OracleWallProvider(config);
|
||||
checkResult = provider.check(sql);
|
||||
resultSql = checkResult.getSql();
|
||||
System.out.println(resultSql);
|
||||
assertEquals("SELECT *\n" +
|
||||
"FROM t\n" +
|
||||
"WHERE ROWNUM <= 10", resultSql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,16 +27,20 @@ public class DistinctTest extends TestCase {
|
||||
|
||||
public void test_mysql() throws Exception {
|
||||
Assert.assertEquals("SELECT count(DISTINCT *)\nFROM t", SQLUtils.format(sql, JdbcUtils.MYSQL));
|
||||
Assert.assertEquals("SELECT count(DISTINCT *)\nFROM t", SQLUtils.format(sql, JdbcUtils.OCEANBASE));
|
||||
}
|
||||
|
||||
public void test_oracle() throws Exception {
|
||||
Assert.assertEquals("SELECT count(DISTINCT *)\nFROM t", SQLUtils.format(sql, JdbcUtils.ORACLE));
|
||||
Assert.assertEquals("SELECT count(DISTINCT *)\nFROM t", SQLUtils.format(sql, JdbcUtils.OCEANBASE_ORACLE));
|
||||
Assert.assertEquals("SELECT count(DISTINCT *)\nFROM t", SQLUtils.format(sql, JdbcUtils.ALI_ORACLE));
|
||||
}
|
||||
|
||||
public void test_oracle_unique() throws Exception {
|
||||
Assert.assertEquals("SELECT count(UNIQUE *)\nFROM t",
|
||||
SQLUtils.format("select count(unique *) from t", JdbcUtils.ORACLE));
|
||||
Assert.assertEquals("SELECT count(UNIQUE *)\nFROM t",
|
||||
SQLUtils.format("select count(unique *) from t", JdbcUtils.OCEANBASE_ORACLE));
|
||||
Assert.assertEquals("SELECT count(UNIQUE *)\nFROM t",
|
||||
SQLUtils.format("select count(unique *) from t", JdbcUtils.ALI_ORACLE));
|
||||
}
|
||||
|
||||
@@ -28,10 +28,12 @@ public class MybatisTest extends TestCase {
|
||||
|
||||
public void test_mysql() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = #{id}", SQLUtils.format(sql, JdbcUtils.MYSQL));
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = #{id}", SQLUtils.format(sql, JdbcUtils.OCEANBASE));
|
||||
}
|
||||
|
||||
public void test_oracle() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = #{id}", SQLUtils.format(sql, JdbcUtils.ORACLE));
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = #{id}", SQLUtils.format(sql, JdbcUtils.OCEANBASE_ORACLE));
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = #{id}", SQLUtils.format(sql, JdbcUtils.ALI_ORACLE));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,12 @@ public class MybatisTest2 extends TestCase {
|
||||
|
||||
public void test_mysql() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = ${id}", SQLUtils.format(sql, JdbcUtils.MYSQL));
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = ${id}", SQLUtils.format(sql, JdbcUtils.OCEANBASE));
|
||||
}
|
||||
|
||||
public void test_oracle() throws Exception {
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = ${id}", SQLUtils.format(sql, JdbcUtils.ORACLE));
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = ${id}", SQLUtils.format(sql, JdbcUtils.OCEANBASE_ORACLE));
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE id = ${id}", SQLUtils.format(sql, JdbcUtils.ALI_ORACLE));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@ public class PagerUtilsTest_Count_MySql_0 extends TestCase {
|
||||
String result = PagerUtils.count(sql, JdbcConstants.MYSQL);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
}
|
||||
|
||||
public void test_mysql_1() throws Exception {
|
||||
@@ -23,6 +26,9 @@ public class PagerUtilsTest_Count_MySql_0 extends TestCase {
|
||||
String result = PagerUtils.count(sql, JdbcConstants.MYSQL);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
}
|
||||
|
||||
public void test_mysql_2() throws Exception {
|
||||
@@ -30,13 +36,19 @@ public class PagerUtilsTest_Count_MySql_0 extends TestCase {
|
||||
String result = PagerUtils.count(sql, JdbcConstants.MYSQL);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
}
|
||||
|
||||
|
||||
public void test_mysql_3() throws Exception {
|
||||
String sql = "select distinct id from t order by id";
|
||||
String result = PagerUtils.count(sql, JdbcConstants.MYSQL);
|
||||
Assert.assertEquals("SELECT COUNT(DISTINCT id)\n" + //
|
||||
"FROM t", result);
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE);
|
||||
Assert.assertEquals("SELECT COUNT(DISTINCT id)\n" + //
|
||||
"FROM t", result);
|
||||
}
|
||||
|
||||
public void test_mysql_4() throws Exception {
|
||||
@@ -44,6 +56,9 @@ public class PagerUtilsTest_Count_MySql_0 extends TestCase {
|
||||
String result = PagerUtils.count(sql, JdbcConstants.MYSQL);
|
||||
assertEquals("SELECT COUNT(DISTINCT a.col1, a.col2)\n" +
|
||||
"FROM test a", result);
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE);
|
||||
assertEquals("SELECT COUNT(DISTINCT a.col1, a.col2)\n" +
|
||||
"FROM test a", result);
|
||||
}
|
||||
|
||||
public void test_mysql_group_0() throws Exception {
|
||||
@@ -55,6 +70,14 @@ public class PagerUtilsTest_Count_MySql_0 extends TestCase {
|
||||
"\tFROM t\n" +
|
||||
"\tGROUP BY type\n" +
|
||||
") ALIAS_COUNT", result);
|
||||
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" +
|
||||
"FROM (\n" +
|
||||
"\tSELECT type, count(*)\n" +
|
||||
"\tFROM t\n" +
|
||||
"\tGROUP BY type\n" +
|
||||
") ALIAS_COUNT", result);
|
||||
}
|
||||
|
||||
public void test_mysql_union_0() throws Exception {
|
||||
@@ -68,6 +91,15 @@ public class PagerUtilsTest_Count_MySql_0 extends TestCase {
|
||||
"\tSELECT id, name\n" +
|
||||
"\tFROM t2\n" +
|
||||
") ALIAS_COUNT", result);
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" +
|
||||
"FROM (\n" +
|
||||
"\tSELECT id, name\n" +
|
||||
"\tFROM t1\n" +
|
||||
"\tUNION\n" +
|
||||
"\tSELECT id, name\n" +
|
||||
"\tFROM t2\n" +
|
||||
") ALIAS_COUNT", result);
|
||||
}
|
||||
|
||||
public void test_mysql_select() throws Exception {
|
||||
@@ -76,5 +108,10 @@ public class PagerUtilsTest_Count_MySql_0 extends TestCase {
|
||||
assertEquals("SELECT *\n" +
|
||||
"FROM t\n" +
|
||||
"LIMIT 10, 10", stmt.toString());
|
||||
stmt = (SQLSelectStatement) SQLUtils.parseStatements("select * from t", JdbcConstants.OCEANBASE).get(0);
|
||||
PagerUtils.limit(stmt.getSelect(), stmt.getDbType(), 10, 10);
|
||||
assertEquals("SELECT *\n" +
|
||||
"FROM t\n" +
|
||||
"LIMIT 10, 10", stmt.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ public class PagerUtilsTest_Count_Oracle_0 extends TestCase {
|
||||
String result = PagerUtils.count(sql, JdbcConstants.ORACLE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE_ORACLE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
}
|
||||
|
||||
public void test_oracle_1() throws Exception {
|
||||
@@ -21,6 +24,9 @@ public class PagerUtilsTest_Count_Oracle_0 extends TestCase {
|
||||
String result = PagerUtils.count(sql, JdbcConstants.ORACLE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE_ORACLE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
}
|
||||
|
||||
public void test_oracle_2() throws Exception {
|
||||
@@ -28,6 +34,9 @@ public class PagerUtilsTest_Count_Oracle_0 extends TestCase {
|
||||
String result = PagerUtils.count(sql, JdbcConstants.ORACLE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE_ORACLE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" + //
|
||||
"FROM t", result);
|
||||
}
|
||||
|
||||
public void test_oracle_group_0() throws Exception {
|
||||
@@ -39,6 +48,14 @@ public class PagerUtilsTest_Count_Oracle_0 extends TestCase {
|
||||
"\tFROM t\n" +
|
||||
"\tGROUP BY type\n" +
|
||||
") ALIAS_COUNT", result);
|
||||
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE_ORACLE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" +
|
||||
"FROM (\n" +
|
||||
"\tSELECT type, count(*)\n" +
|
||||
"\tFROM t\n" +
|
||||
"\tGROUP BY type\n" +
|
||||
") ALIAS_COUNT", result);
|
||||
}
|
||||
|
||||
public void test_oracle_union_0() throws Exception {
|
||||
@@ -52,5 +69,15 @@ public class PagerUtilsTest_Count_Oracle_0 extends TestCase {
|
||||
"\tSELECT id, name\n" +
|
||||
"\tFROM t2\n" +
|
||||
") ALIAS_COUNT", result);
|
||||
|
||||
result = PagerUtils.count(sql, JdbcConstants.OCEANBASE_ORACLE);
|
||||
Assert.assertEquals("SELECT COUNT(*)\n" +
|
||||
"FROM (\n" +
|
||||
"\tSELECT id, name\n" +
|
||||
"\tFROM t1\n" +
|
||||
"\tUNION\n" +
|
||||
"\tSELECT id, name\n" +
|
||||
"\tFROM t2\n" +
|
||||
") ALIAS_COUNT", result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public class MergeTest extends TestCase {
|
||||
String sql = "{ call INTERFACE_DATA_EXTRACTION.INVOICE_INFO(?,?,?)}";
|
||||
|
||||
ParameterizedOutputVisitorUtils.parameterize(sql, JdbcUtils.ORACLE);
|
||||
ParameterizedOutputVisitorUtils.parameterize(sql, JdbcUtils.OCEANBASE_ORACLE);
|
||||
ParameterizedOutputVisitorUtils.parameterize(sql, JdbcUtils.ALI_ORACLE);
|
||||
}
|
||||
|
||||
@@ -39,5 +40,6 @@ public class MergeTest extends TestCase {
|
||||
String sql = "{ call INTERFACE_DATA_EXTRACTION.INVOICE_INFO(?,?,?)}";
|
||||
|
||||
ParameterizedOutputVisitorUtils.parameterize(sql, JdbcUtils.MYSQL);
|
||||
ParameterizedOutputVisitorUtils.parameterize(sql, JdbcUtils.OCEANBASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ public class OracleFormatTest2 extends TestCase {
|
||||
|
||||
String formatedText = SQLUtils.format(text, JdbcUtils.ORACLE);
|
||||
System.out.println(formatedText);
|
||||
String formatedText1 = SQLUtils.format(text, JdbcUtils.OCEANBASE_ORACLE);
|
||||
System.out.println(formatedText1);
|
||||
String formatedText2 = SQLUtils.format(text, JdbcUtils.ALI_ORACLE);
|
||||
System.out.println(formatedText2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user